TokenMoo

Chat completions

Send conversation messages and read the assistant reply.

POST /v1/chat/completions is the main endpoint for chat and reasoning models.

Request

curl https://www.tokenmoo.com/v1/chat/completions \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Summarise this in one sentence: ..." }
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'

Message roles

RolePurpose
systemInstructions that apply to the whole conversation
userInput from the caller
assistantPrevious model replies, for multi-turn context

Multi-turn conversations

Send the full history on every request — the API is stateless:

{
  "model": "gpt-4o-mini",
  "messages": [
    { "role": "user", "content": "What is TokenMoo?" },
    { "role": "assistant", "content": "TokenMoo is a unified AI API gateway." },
    { "role": "user", "content": "How do I call it?" }
  ]
}

Practical tips

  • Keep system short and explicit; it is billed as input tokens.
  • Set max_tokens to bound cost and latency for interactive applications.
  • Lower temperature (0–0.3) for factual output, higher for creative output.
  • Prefer streaming for chat UIs so the user sees tokens as they arrive.

On this page