Anthropic compatibility
Set the Anthropic client’s base URL to https://api.saygm.com. The SDK adds
/v1/messages and sends the GM key through the native x-api-key header.
Python
Section titled “Python”import osfrom anthropic import Anthropic
client = Anthropic( base_url="https://api.saygm.com", api_key=os.environ["GM_API_KEY"],)
message = client.messages.create( model="claude-opus-4-8", max_tokens=1024, messages=[{"role": "user", "content": "Say gm."}],)print(message.content[0].text)Node.js
Section titled “Node.js”import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.saygm.com", apiKey: process.env.GM_API_KEY,});
const message = await client.messages.create({ model: "claude-opus-4-8", max_tokens: 1024, messages: [{ role: "user", content: "Say gm." }],});console.log(message.content[0].text);Discover compatible models with:
curl -fsSL "https://api.saygm.com/v1/models?api_shape=messages"Usage and cost
Section titled “Usage and cost”Every successful response carries settled cost inside usage, alongside the
normal token counts:
{ "usage": { "input_tokens": 12, "output_tokens": 9, "cost": 0.000140000, "cost_nano_usd": 140000 }}cost is USD, rendered as a JSON number with exactly nine fractional digits —
the amount actually settled against the account’s prepaid balance, not an
estimate from /v1/models rates. cost_nano_usd is the same amount as an
integer in nano-USD (1 nUSD = 10⁻⁹ USD), matching GET /v1/credits. Error
responses carry neither field. See
per-request cost for how to use the
figure.