Skip to content

Python Integration

When using the official openai Python SDK, simply override the client initialization parameters.

Code Example

import openai
client = openai.OpenAI(
api_key="sk-xxx...xxxx", # Enter your KoboiLLM API Key
base_url="https://api.koboillm.com/v1" # Point Base URL to KoboiLLM
)
response = client.chat.completions.create(
model="openai/gpt-4o-mini", # Or any supported model e.g., anthropic/claude-3-5-sonnet, gemini/gemini-2.5-flash
messages=[
{"role": "user", "content": "this is a test request, write a short poem"}
]
)
print(response.choices[0].message.content)

Required Configuration

ParameterValue
API Keysk-xxxx (Virtual Key from Dashboard)
Base URLhttps://api.koboillm.com/v1
ModelAny active model ID (e.g., openai/gpt-4o-mini, anthropic/claude-3-5-sonnet, gemini/gemini-2.5-flash)

Best Practices

  • Install the official library: pip install openai
  • Set api_key via environment variable (OPENAI_API_KEY) for better security.
  • Specify model names using provider/model format where applicable.