Skip to content

Command Palette

Search for a command to run...

Chat API

One endpoint for every conversational model on the platform — with streaming, tool calling, structured JSON output and optional persistent memory.

Create a completion

POST/v1/chat/completions

Send a list of messages and receive the assistant's reply. The request shape is identical across all models, so switching models is a one-line change.

terminalbash
curl https://api.tapotik.ai/v1/chat/completions \
  -H "Authorization: Bearer $TAPOTIK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tapotik-2-pro",
    "messages": [
      { "role": "system", "content": "You are a concise support agent." },
      { "role": "user", "content": "How do credits roll over?" }
    ],
    "temperature": 0.4,
    "max_tokens": 600
  }'
app/chat.tstypescript
const completion = await client.chat.completions.create({
  model: "tapotik-2-pro",
  messages: [
    { role: "system", content: "You are a concise support agent." },
    { role: "user", content: "How do credits roll over?" },
  ],
  temperature: 0.4,
  max_tokens: 600,
});

console.log(completion.choices[0].message.content);
console.log(completion.usage); // { input_tokens, output_tokens, credits }

Request parameters

ParameterTypeDescription
modelstring · requiredModel ID, e.g. tapotik-2-pro or router/auto for smart routing.
messagesarray · requiredConversation history. Roles: system, user, assistant, tool.
streamboolean · default falseStream tokens as server-sent events instead of a single response.
temperaturenumber · 0–2 · default 0.7Higher values increase creativity; lower values increase determinism.
max_tokensintegerHard cap on generated tokens. Defaults to the model maximum.
toolsarrayJSON-schema tool definitions the model may call.
response_formatobjectSet { "type": "json_schema" } with a schema for guaranteed structured output.
memory_idstringAttach a persistent memory store so context survives across sessions.
metadataobjectUp to 16 key-value pairs echoed back in webhooks and the audit log.

Streaming

With stream: true the endpoint returns text/event-stream chunks. The final event is [DONE] and includes usage totals on the preceding chunk.

app/stream.tstypescript
const stream = await client.chat.completions.create({
  model: "router/auto",
  messages: [{ role: "user", content: "Summarize this ticket thread." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Tool calling

Describe functions with JSON Schema and the model will return a tool_calls array when it wants to use one. Execute the call on your side, then append the result as a tool message and continue the loop.

app/tools.tstypescript
const completion = await client.chat.completions.create({
  model: "tapotik-2-pro",
  messages,
  tools: [
    {
      type: "function",
      function: {
        name: "get_invoice",
        description: "Fetch an invoice by ID",
        parameters: {
          type: "object",
          properties: { invoice_id: { type: "string" } },
          required: ["invoice_id"],
        },
      },
    },
  ],
});

const call = completion.choices[0].message.tool_calls?.[0];
// -> { id, function: { name: "get_invoice", arguments: '{"invoice_id":"inv_231"}' } }

Available models

ModelContextBest forCredits / 1K tokens
tapotik-2-pro200KFlagship quality, tools and reasoning1.0
tapotik-2-flash128KHigh-volume, latency-sensitive workloads0.25
router/autovariesSmart routing to the best model per requestmetered by routed model
openai/gpt-4o128KFrontier model via unified API2.0
anthropic/claude-4-sonnet200KLong-context analysis and writing1.8
router/auto requires a Pro plan or above. It routes each request based on prompt complexity, latency targets and your monthly budget — teams typically save 40–60% on credits with no quality loss.

See also: rate limits for throughput per plan, and errors for retry guidance.