Guides

Frameworks

Settings for LangChain, LlamaIndex, the Vercel AI SDK and LiteLLM, and the two settings that cause most connection problems.

A framework that can use the OpenAI chat completions API works with Kontinent AI. Set the base URL to https://api.kontinentai.com/v1 and use a Kontinent AI key. For the SDKs, see OpenAI SDK and Anthropic SDK.

LangChain

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="claude-sonnet-5-5",
    api_key=os.environ["KONTINENT_API_KEY"],
    base_url="https://api.kontinentai.com/v1",
)
import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "claude-sonnet-5-5",
  apiKey: process.env.KONTINENT_API_KEY,
  configuration: { baseURL: "https://api.kontinentai.com/v1" },
});

Use the langchain-openai package. Tool calls work through it on the models that show tools.

LlamaIndex

import os
from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    model="claude-sonnet-5-5",
    api_key=os.environ["KONTINENT_API_KEY"],
    api_base="https://api.kontinentai.com/v1",
    is_chat_model=True,
    is_function_calling_model=True,
)

Vercel AI SDK

Use the @ai-sdk/openai-compatible package:

import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";

const kontinent = createOpenAICompatible({
  name: "kontinent",
  apiKey: process.env.KONTINENT_API_KEY,
  baseURL: "https://api.kontinentai.com/v1",
  includeUsage: true,
});

const result = streamText({
  model: kontinent("claude-sonnet-5-5"),
  prompt: "Explain server-sent events in two sentences.",
});

includeUsage: true asks for the usage frame at the end of a stream. That frame also has our kontinent cost block.

LiteLLM

import os
from litellm import completion

response = completion(
    model="openai/claude-sonnet-5-5",
    messages=[{"role": "user", "content": "Hello"}],
    api_key=os.environ["KONTINENT_API_KEY"],
    api_base="https://api.kontinentai.com/v1",
)

The openai/ prefix tells LiteLLM to use its OpenAI handler. Without the prefix, LiteLLM tries to find the provider from the model name.

Other tools

If a tool accepts a base URL and a key, it can work with Kontinent AI. Two settings cause most problems:

  • A path after /v1. The base URL is https://api.kontinentai.com/v1. Most clients add /chat/completions. If you add it too, the client sends requests to /v1/chat/completions/chat/completions and gets a 404 error.
  • The old completions endpoint. Some tools use /v1/completions by default. We do not have it. Look for a setting for chat models.

If a tool does not work, tell us the name and the version of the tool at team@kontinentai.com.