Integrations
OpenAI SDKs
Configure the official Python and JavaScript SDKs for KosCompute.
OpenAI SDKs can connect to KosCompute by setting the API key and base URL explicitly.
Python¶
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["KOSCOMPUTE_API_KEY"],
base_url="https://api.koscompute.com/v1",
)
completion = client.chat.completions.create(
model="qwen/qwen3.8-27b",
messages=[{"role": "user", "content": "Write a SQL transaction example."}],
max_completion_tokens=300,
)
print(completion.choices[0].message.content)
Install with pip install openai. Keep the key in a server-side environment variable.
JavaScript¶
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.KOSCOMPUTE_API_KEY,
baseURL: "https://api.koscompute.com/v1",
});
const completion = await client.chat.completions.create({
model: "qwen/qwen3.8-27b",
messages: [{ role: "user", content: "Explain MVCC briefly." }],
max_completion_tokens: 240,
});
console.log(completion.choices[0].message.content);
Install with npm install openai. Do not enable browser use with a production key.
Responses¶
The SDK's responses.create method can call KosCompute's stateless Responses endpoint. Use only the fields documented in the Responses guide; an SDK may expose hosted OpenAI features that this compatibility endpoint intentionally rejects.
Generic clients¶
For other OpenAI-compatible libraries, set:
- base URL:
https://api.koscompute.com/v1 - API key:
KOSCOMPUTE_API_KEY - model: a canonical ID from
GET /v1/models
Disable assumptions about OpenAI-specific model names and hosted tools.