Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content
Guides

Frameworks

Each framework on this page speaks the OpenAI, Anthropic or Gemini API. To point one at Mubit, give it Mubit's base URL for that provider and your Mubit key. Keep your model IDs and the rest of your code.

Use the base URL your console's Connect page shows.

The examples read the key from MUBIT_API_KEY. To create a key and set it, follow step 1 of the Quickstart.

Vercel AI SDK

Install the SDK and the provider packages you use: npm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google.

Each provider package takes a baseURL. The AI SDK expects the version path at the end of each one, Anthropic's and Gemini's included:

ProviderbaseURL
OpenAIhttps://api.mubit.ai/openai/v1
Anthropichttps://api.mubit.ai/anthropic/v1
Geminihttps://api.mubit.ai/gemini/v1beta

OpenAI

import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
 
const apiKey = process.env.MUBIT_API_KEY;
if (!apiKey) throw new Error("MUBIT_API_KEY is not set");
 
const openai = createOpenAI({
  baseURL: "https://api.mubit.ai/openai/v1",
  apiKey,
});
 
const { text } = await generateText({
  model: openai("gpt-6-luna"),
  system:
    "Sort the support message into one category: " +
    "billing, bug, account or other. Reply with the category only.",
  prompt: "I was charged twice for my October invoice.",
});
console.log(text);

openai("…") calls the Responses API. For Chat Completions, use openai.chat("…"). Both work through the same base URL.

Anthropic

import { createAnthropic } from "@ai-sdk/anthropic";
import { generateText } from "ai";
 
const apiKey = process.env.MUBIT_API_KEY;
if (!apiKey) throw new Error("MUBIT_API_KEY is not set");
 
const anthropic = createAnthropic({
  baseURL: "https://api.mubit.ai/anthropic/v1",
  apiKey,
});
 
const { text } = await generateText({
  model: anthropic("claude-haiku-4-5"),
  system:
    "Sort the support message into one category: " +
    "billing, bug, account or other. Reply with the category only.",
  prompt: "I was charged twice for my October invoice.",
});
console.log(text);

Gemini

ℹ️Note

If the console doesn't list Gemini under the starter credit, add your Gemini key under Provider keys first, as the Provider keys page shows.

import { createGoogleGenerativeAI } from "@ai-sdk/google";
import { generateText } from "ai";
 
const apiKey = process.env.MUBIT_API_KEY;
if (!apiKey) throw new Error("MUBIT_API_KEY is not set");
 
const google = createGoogleGenerativeAI({
  baseURL: "https://api.mubit.ai/gemini/v1beta",
  apiKey,
});
 
const { text } = await generateText({
  model: google("gemini-3.8-flash"),
  system:
    "Sort the support message into one category: " +
    "billing, bug, account or other. Reply with the category only.",
  prompt: "I was charged twice for my October invoice.",
});
console.log(text);

The examples use top-level await, so run them as ES modules: give the file an .mts name, for example vercel-openai.mts, and run npx tsx vercel-openai.mts, or add "type": "module" to your package.json.

Tested with ai 7.0.148, @ai-sdk/openai 4.0.99, @ai-sdk/anthropic 4.0.85 and @ai-sdk/google 4.0.102.

LangChain

Install the packages you use: pip install langchain-openai langchain-anthropic for Python, or npm install @langchain/openai @langchain/anthropic @langchain/core for TypeScript.

ChatOpenAI

Give ChatOpenAI the OpenAI base URL, which ends in /v1. In Python it's base_url; in TypeScript it goes under configuration.

Python
import os
from langchain_openai import ChatOpenAI
 
llm = ChatOpenAI(
    model="gpt-6-luna",
    base_url="https://api.mubit.ai/openai/v1",
    api_key=os.environ["MUBIT_API_KEY"],
)
 
reply = llm.invoke([
    ("system", "Sort the support message into one category: "
               "billing, bug, account or other. Reply with the category only."),
    ("human", "I was charged twice for my October invoice."),
])
print(reply.content)

ChatAnthropic

Give ChatAnthropic the Anthropic base URL. Leave /v1 off the end: the Anthropic SDK underneath adds it. In Python it's base_url; in TypeScript it's anthropicApiUrl.

ℹ️Note

Send your Mubit key only. If ANTHROPIC_AUTH_TOKEN holds another credential, the TypeScript ChatAnthropic sends it beside your key, and Mubit refuses the call with a 401. Unset it, or set it to your Mubit key.

Python
import os
from langchain_anthropic import ChatAnthropic
 
llm = ChatAnthropic(
    model="claude-haiku-4-5",
    base_url="https://api.mubit.ai/anthropic",
    api_key=os.environ["MUBIT_API_KEY"],
)
 
reply = llm.invoke([
    ("system", "Sort the support message into one category: "
               "billing, bug, account or other. Reply with the category only."),
    ("human", "I was charged twice for my October invoice."),
])
print(reply.content)

LangChain also reads the SDKs' environment variables. With OPENAI_BASE_URL and OPENAI_API_KEY set as the OpenAI page shows, or ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY as the Anthropic page shows, leave out the base URL and the key.

Run the TypeScript examples as ES modules, as for the AI SDK above.

Tested with langchain-openai 1.7.2 and langchain-anthropic 1.7.6 for Python, and @langchain/openai 1.6.3, @langchain/anthropic 1.5.13 and @langchain/core 1.2.20 for TypeScript.

OpenAI Agents SDK

⚠️Warning

Turn the SDK's tracing off before anything else. With tracing on, the SDK uploads each run's trace, prompts and replies included, to OpenAI directly. The Python SDK signs it with the key of the client you give it, which is your Mubit key. The TypeScript SDK uses OPENAI_API_KEY, which holds your Mubit key if you set it as the OpenAI page shows. Each example below turns tracing off in its first lines.

Install the SDK: pip install openai-agents for Python, or npm install @openai/agents openai zod for TypeScript.

Give the SDK an OpenAI client with the OpenAI base URL and your Mubit key, and make it the default client:

Python
import os
from openai import AsyncOpenAI
from agents import Agent, Runner, set_default_openai_client, set_tracing_disabled
 
# Before anything else: with tracing on, the SDK sends your Mubit key to OpenAI.
set_tracing_disabled(True)
 
set_default_openai_client(
    AsyncOpenAI(
        base_url="https://api.mubit.ai/openai/v1",
        api_key=os.environ["MUBIT_API_KEY"],
    )
)
 
agent = Agent(
    name="Support triage",
    instructions="Sort the support message into one category: "
                 "billing, bug, account or other. Reply with the category only.",
    model="gpt-6-luna",
)
 
result = Runner.run_sync(agent, "I was charged twice for my October invoice.")
print(result.final_output)

The SDK calls the Responses API. Mubit takes it on the same base URL. Run the TypeScript example as an ES module, as for the AI SDK above.

Tested with openai-agents 0.24.0 and openai 3.36.0 for Python, and @openai/agents 0.21.0 and openai 7.41.0 for TypeScript.

See the calls in Requests

Each call shows in Requests like any other: open it in the console and find the call at the top. Model asked shows the model ID your app sent.

If a call fails

The error names its code. Troubleshooting lists the codes and what to do.

Next