Studios

Chat Completions

The OpenAI chat format on the full menu, billed per token.

Create a chat completion

POST/api/v1/chat/completionsPer token

Send a conversation and get the model's reply. The request and response match OpenAI's, so any OpenAI SDK works once its base URL points at the Gateway.

Request body

modelstringrequiredA model id from the menu. Send clawhunter/free for the day's free model, or clawhunter/smart to let Smart Router pick.
messagesobject[]requiredThe conversation, oldest first. Each message has a role and content. Content is text, or an array of text and image parts.system · user · assistant
max_tokensintegerThe most tokens the reply can use. Defaults to 1024, up to 8192. max_completion_tokens works too.
streambooleanStream the reply as server-sent events. The last chunk carries usage. Needs an API key.
toolsobject[]Functions the model can call, in OpenAI's format. Works on models that support tool calls.
tool_choicestring | objectWhether and which tool the model must call, as in OpenAI's API.

Other OpenAI parameters, like temperature, pass through to the model.

Example request

import OpenAI from "openai";​const client = new OpenAI({  apiKey: process.env.CLAWHUNTER_API_KEY,  baseURL: "https://mystudios.fun/api/v1",});​const response = await client.chat.completions.create({  model: "clawhunter/smart",  messages: [{ role: "user", content: "Debug this race condition" }],});

Response

An OpenAI chat completion with a billing block added. It names the model that answered and what the call cost. Smart Router calls also show the difficulty and the list price of the same tokens.

Response
{  "id": "chatcmpl-…",  "object": "chat.completion",  "model": "claude-opus-5-5",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": "Two threads read and write the same counter…"      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 14,    "completion_tokens": 900,    "total_tokens": 914  },  "billing": {    "model": "claude-opus-5-5",    "requested_model": "clawhunter/smart",    "difficulty": "hard",    "input_tokens_billed": 14,    "output_tokens_billed": 900,    "usd": 0.009028,    "usage_usd": 0.009028,    "quote_usd": 0.02567,    "list_usd": 0.018056,    "ceiling_usd": 0.011285,    "note": "routed to Claude Opus 5.5 (hard)"  }}

Billing and limits

  • Billed per token at the model's rates, listed on Models.
  • With credits, the call reserves your input plus max_tokens, then settles for what you used.
  • With x402, you pay that reserve as the price. Set max_tokens near the reply you expect.
  • max_tokens defaults to 1024 and caps at 8192.
  • Input caps at 200,000 characters. A larger request returns 413.
  • Streaming and clawhunter/smart need an API key.
  • Eligible models draw on your daily free allowance first.
  • One reply per request. n must be 1 or left out.
  • A rejected or failed request is not charged.