SDKs

OpenAI SDK

The official openai packages work against xKiro with two configuration changes.

1

Install

pip install openai
2

Point the client at xKiro

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["XKIRO_API_KEY"],
    base_url="https://api.xkiro.com/v1",
)

The base URL ends in /v1

The OpenAI SDKs append paths like /chat/completions to whatever you give them. Omit /v1 and every request 404s.

3

Call a model

res = client.chat.completions.create(
    model="openai/gpt-5.6-sol",
    messages=[{"role": "user", "content": "Hello"}],
)

print(res.choices[0].message.content)

Model IDs carry a vendor prefix. See Models.

4

Stream when the answer is long

stream = client.chat.completions.create(
    model="openai/gpt-5.6-sol",
    messages=[{"role": "user", "content": "Write a haiku about caching."}],
    stream=True,
)

for chunk in stream:
    if delta := chunk.choices[0].delta.content:
        print(delta, end="", flush=True)

What works#

  • chat.completions.create — blocking and streaming.
  • models.list — the catalog.
  • Tool calling, vision content parts, JSON mode and reasoning effort.
  • The SDK's own error classes, because error shapes are unchanged.

Timeouts and retries#

Configure both explicitly. The defaults are tuned for OpenAI's latency profile, and a long reasoning request can outlive them.

const client = new OpenAI({
  apiKey: process.env.XKIRO_API_KEY,
  baseURL: "https://api.xkiro.com/v1",

  // Comfortably above the 95-second blocking limit, so a slow-but-healthy
  // request is not killed by the client before the server answers.
  timeout: 120_000,

  // The SDK retries on its own. Two is plenty: xKiro already fails over
  // between routes internally, so extra client retries mostly add latency.
  maxRetries: 2,
});

Retries do not double-bill

An identical blocking request sent again within a couple of minutes replays the first result instead of running twice. See Idempotency.

Cancelling#

const controller = new AbortController();
stopButton.onclick = () => controller.abort();

const stream = await client.chat.completions.create(
  { model: "openai/gpt-5.6-sol", messages, stream: true },
  { signal: controller.signal },
);

Aborting stops the upstream call, so you are billed only for what was generated before that point.

Anything built on the SDK

LangChain, LlamaIndex, Vercel AI SDK and similar libraries accept a base URL and an API key. Set those two and they work — they are calling the same client underneath.