Connect your tools

OpenAI SDK

Set the base URL and the key in the OpenAI Python or Node SDK. Then use chat completions for Claude, GPT and Gemini, and Responses for GPT.

Or let your agent do it

Paste the prompt into your coding agent. The agent writes the configuration and tests it.

The OpenAI SDKs work with Kontinent AI. Change two settings: the base URL and the key. Keep the rest of your code.

1. Install the SDK

pip install openai
npm install openai

2. Set the base URL and the key

Use https://api.kontinentai.com/v1 as the base URL. Use your Kontinent AI key as the API key.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["KONTINENT_API_KEY"],
    base_url="https://api.kontinentai.com/v1",
)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.KONTINENT_API_KEY,
  baseURL: "https://api.kontinentai.com/v1",
});

The SDKs also read two environment variables. If you set them, you can call OpenAI() with no arguments:

export OPENAI_BASE_URL="https://api.kontinentai.com/v1"
export OPENAI_API_KEY="$KONTINENT_API_KEY"

3. Send a chat completion

reply = client.chat.completions.create(
    model="gemini-3.5-flash",
    messages=[{"role": "user", "content": "Name three long rivers."}],
)
print(reply.choices[0].message.content)
print(reply.model_extra["kontinent"])
const reply = await client.chat.completions.create({
  model: "gemini-3.5-flash",
  messages: [{ role: "user", content: "Name three long rivers." }],
});
console.log(reply.choices[0].message.content);
console.log(reply.kontinent);

If the program prints an answer and a kontinent block with cost_usd, the connection works.

These models work on /v1/chat/completions:

  • claude-opus-5-5
  • claude-opus-5
  • claude-sonnet-5-5
  • claude-sonnet-5
  • claude-haiku-4-5-20251001
  • claude-fable-5-1
  • gpt-5.5
  • gpt-6.1-sol
  • gpt-5
  • gemini-3.1-pro-preview
  • gemini-3.5-flash
  • glm-5.3
  • qwen3.8-max
  • deepseek-v4.1-flash

Send a Responses request

The Responses endpoint serves the GPT models only.

response = client.responses.create(
    model="gpt-5.5",
    input="Name three long rivers.",
)
print(response.output_text)
const response = await client.responses.create({
  model: "gpt-5.5",
  input: "Name three long rivers.",
});
console.log(response.output_text);

These models work on /v1/responses:

  • gpt-5.5
  • gpt-6.1-sol
  • gpt-5

Retries

The SDKs retry 429 and 5xx errors with backoff. They do not retry 402, because a low balance does not change when you send the request again. To change the number of retries, set max_retries in Python or maxRetries in Node.

Next steps