Move your SDK to Moth by changing one line
Point the base URL at the Mothpoint and pass your moth_ key, and the chat SDKs and agents you run today keep working, now without telling the host who you are.
Key points
- Point your SDK's base URL at the Mothpoint and pass a moth_ key, and the rest of your code stays as it is.
- The OpenAI and Anthropic request formats both work, so most agents and frameworks built on them do too.
- Fields your SDK adds by itself are dropped at the Mothpoint, along with the identity they carry.
The line that changes
Most projects that call a model make their client in one place, a few lines near the top of a file. Moving to Moth happens there, and nowhere else.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["PROVIDER_API_KEY"])
client = OpenAI(base_url="https://api.runmoth.ai/v1", api_key=os.environ["MOTH_API_KEY"])
reply = client.chat.completions.create(
model="gemini-3.8-flash",
messages=[{"role": "user", "content": "Hello"}],
)
The model field takes any chat model ID from the catalog, so gemini-3.8-flash could be claude-sonnet-5.5 or gpt-6-astra without touching another line. The same change in TypeScript looks like this.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.runmoth.ai/v1", apiKey: process.env.MOTH_API_KEY });
const reply = await client.chat.completions.create({
model: "gemini-3.8-flash",
messages: [{ role: "user", content: "Hello" }],
});
The Anthropic SDK works too
If your code is written against the Messages format, point the Anthropic SDK at the Mothpoint the same way. Its base URL leaves off the /v1, because that SDK adds it itself.
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.runmoth.ai", api_key=os.environ["MOTH_API_KEY"])
reply = client.messages.create(
model="claude-sonnet-5.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
What keeps working
Streaming, tool calls and structured output pass through in the format your SDK already sends, on the models that support them. Most agents and frameworks that let you set a base URL work the same way, since they are built on these SDKs.
- 1
- line changed in your code
- 2
- request formats taken, OpenAI's and Anthropic's
- 29
- chat models behind the same client
Fields your SDK adds on its own are handled quietly. The Mothpoint keeps only the fields each endpoint names and drops the rest without an error, so user, metadata and the like never travel on, and the identity they carry stops with them.
- Streamingtoken by token, in the format your SDK expects
- Tool callson every model that takes tools
- Structured outputwhere the model supports the schema
- Your model IDsany chat model in the catalog, one field to change
- user, metadata and storedropped at the Mothpoint, with no error
- Images, video and musicthe same key, as jobs you follow
- Sealed modelsin Moth Chat and Moth Console, which encrypt in your browser
- Settings a model can't takelisted under capabilities in the catalog
The change is one line of code, and the request that leaves on the other side no longer says who you are.
Worth checking before you switch
Settings per model
Some settings, such as
temperatureorstop, reach only the models that take them. Each model's entry in the catalog lists what it accepts undercapabilities.Image, video and music run as jobs through the same key rather than as chat calls, and the docs show each one.
Sealed models run in Moth Chat and Moth Console, whose browser checks the hardware and encrypts the request before it leaves.
Your first call
Make a key in Moth Console, set it as MOTH_API_KEY in your environment, and run either example above. The reply carries headers with what the call was charged, and every call shows in your activity with its tokens and cost.
Read further
Try Moth
Open Moth Chat in your browser, or get a key and point the SDK you already use at the Mothpoint.