Skip to Content
coaadedocs

Call models

Call Coaade Mind 1.0 and Coaade Code 2.0 from your own code with an API key, using the chat completions endpoint.

Call Coaade's models from your own code with a coaade_sk_ API key. It's a plain HTTPS API: send a JSON request and get the answer back as JSON, or as a stream of Server-Sent Events. Any HTTP client works.

You name the model you want. Coaade routes the call through its pipeline to that model and returns the answer. You never connect to a model provider yourself.

What you need

  • An API key with the Call models permission turned on. Create or edit keys in the Coaade Console, or in coaade.com Settings → API keys & MCP. See API keys.
  • The base URL https://api.coaade.com/v1.

A key is MCP-only until you turn on Call models. A key without that permission gets 403 model_access_disabled.

Endpoints

POST/v1/chat/completionsAPI key

Send a conversation, get a completion. Set stream: true for Server-Sent Events.

GET/v1/modelsAPI key

List the models this key can call. The list depends on the key owner's plan.

Quickstart

Send the key as Authorization: Bearer coaade_sk_…. The examples read it from the COAADE_API_KEY environment variable.

curl https://api.coaade.com/v1/chat/completions \
  -H "Authorization: Bearer $COAADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "coaade-mind-1",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Write a haiku about databases." }
    ]
  }'

Choosing a model

Name the model in the model field. GET /v1/models returns the ids your key can use.

Model idNamePlans
coaade-mind-1Coaade Mind 1.0All plans
coaade-code-2Coaade Code 2.0Paid plans (Pro, Team, Enterprise)
  • An unknown model id returns 404 model_not_found.
  • A model your plan can't use returns 403 model_not_in_plan. For example, coaade-code-2 on the Free plan.
  • coaade-mind-1.0 and coaade-code-2.0 are accepted as aliases. Responses echo the short id (coaade-mind-1, coaade-code-2).

See Models and skills for more on each model.

Streaming

Set stream: true to receive the answer as it's written, over Server-Sent Events. Each event is a data: line holding one chat.completion.chunk object as JSON; the stream ends with data: [DONE].

curl https://api.coaade.com/v1/chat/completions \
  -H "Authorization: Bearer $COAADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "coaade-mind-1",
    "messages": [{ "role": "user", "content": "Count to five." }],
    "stream": true,
    "stream_options": { "include_usage": true }
  }'

A chunk looks like this:

{
  "id": "chatcmpl-8d2e…",
  "object": "chat.completion.chunk",
  "created": 1767225600,
  "model": "coaade-mind-1",
  "choices": [{ "index": 0, "delta": { "content": "One, two," }, "finish_reason": null }]
}

Every chunk in a stream has the same id, created and model. The first chunk carries the assistant role, with delta set to { "role": "assistant", "content": "" }. Each chunk after it adds a slice of the answer in choices[0].delta.content; concatenate them. The last one has an empty delta and finish_reason set. With stream_options.include_usage, one more chunk follows with the token usage and an empty choices array, then data: [DONE].

The stream can also carry keep-alive comment lines that start with :; skip them. If the request fails after the stream has started, the last event before data: [DONE] is an error object in the shape described under Errors.

To read the stream, take it line by line and parse each data: line:

import json
import os

import requests

with requests.post(
    "https://api.coaade.com/v1/chat/completions",
    headers={"Authorization": f"Bearer {os.environ['COAADE_API_KEY']}"},
    json={
        "model": "coaade-mind-1",
        "messages": [{"role": "user", "content": "Count to five."}],
        "stream": True,
    },
    stream=True,
    timeout=60,
) as response:
    response.raise_for_status()
    for line in response.iter_lines():
        # Skip blank lines, keep-alive comments and the end marker.
        if not line.startswith(b"data: ") or line == b"data: [DONE]":
            continue
        chunk = json.loads(line.removeprefix(b"data: "))
        if "error" in chunk:
            raise RuntimeError(chunk["error"]["message"])
        for choice in chunk["choices"]:
            print(choice["delta"].get("content", ""), end="", flush=True)

reasoning_effort

Coaade Mind 1.0 can think before it answers. Set reasoning_effort to control how much:

ValueEffect
offNo thinking. Fastest.
lowDefault. A short planning step.
highMore thinking for harder problems.

The model's thinking is never returned; you get only the final answer. Other models ignore this parameter.

{
  "model": "coaade-mind-1",
  "messages": [{ "role": "user", "content": "Plan a schema for a blog." }],
  "reasoning_effort": "high"
}

Parameters

Prop

Type

Each message is { "role": "...", "content": "..." }. Roles are system, user, assistant and tool. A developer message is also accepted and treated like a system message. content is text: a string, or an array of { "type": "text", "text": "..." } parts. Image, audio and file parts return 400 unsupported_content. An assistant message can carry tool_calls, and a tool message carries the tool_call_id it answers: see Tool calling.

A system message sets the assistant's instructions, persona and output format. Use it to tell the model who it is and how to answer.

The model calls only the tools you define in tools, and your code runs them. Coaade's own tools, such as web search, aren't available through this API.

Response

A non-streamed response is a chat.completion object. choices holds one choice, whose message is the assistant's answer.

Response 200
{
  "id": "chatcmpl-8d2e…",
  "object": "chat.completion",
  "created": 1767225600,
  "model": "coaade-mind-1",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Rows wait in silence…" },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": { "prompt_tokens": 18, "completion_tokens": 24, "total_tokens": 42 }
}
  • finish_reason is stop when the model finished, tool_calls when it asks you to call tools (see Tool calling), or length when the answer hit max_tokens (or another output cap). A cut answer is not continued.
  • usage reports the token counts for the request.
  • created is a Unix timestamp in seconds. logprobs is always null.
  • Each response carries an x-request-id header, matching the id. Quote it if you contact support.

Tool calling

Give the model functions it can call, such as a weather lookup or a database query. Describe each one in tools. When the model wants to use one, the reply carries tool_calls instead of an answer (or with a short one), and finish_reason is tool_calls.

Coaade never runs a tool. Your code runs the call, sends the result back in a tool message, and calls the API again. Both coaade-mind-1 and coaade-code-2 take tools.

The tool loop

Send the conversation with your tools.

If finish_reason is tool_calls, run each call in message.tool_calls. A call has an id, the function's name and its arguments: a JSON object, as a string. Parse the arguments and check them before you use them, since the model wrote them.

Add the assistant message to the conversation as you got it, tool_calls included. Then add one tool message per call: { "role": "tool", "tool_call_id": "<the call's id>", "content": "<the result, as text>" }.

Call the API again with the same tools. Repeat until finish_reason is stop. Give the loop a step limit, so a model that keeps calling tools can't run it forever.

Every call needs its own tool message, after the assistant message that made it and before the next user or assistant message. The tool messages for one reply can come in any order. A reply only calls tools you defined, and its arguments are exactly what the model wrote. A reply cut off by max_tokens (finish_reason length) may hold a call with incomplete arguments: don't send that one back, raise max_tokens and ask again.

Defining tools

{
  "type": "function",
  "function": {
    "name": "get_weather",
    "description": "Get the current weather in a city.",
    "parameters": {
      "type": "object",
      "properties": {
        "city": { "type": "string", "description": "The city, such as Paris" }
      },
      "required": ["city"]
    }
  }
}
  • name: 1 to 64 letters, digits, underscores or dashes, different for each tool.
  • description: what the tool does and when to use it. The model reads it to decide.
  • parameters: a JSON Schema for the arguments object, with "type": "object". Leave it out for a tool that takes no arguments.
  • A request takes up to 128 tools, and the tools array may be at most 200,000 characters as JSON. Tool definitions count toward the model's context, like the messages.

tool_choice controls whether the model calls a tool:

ValueEffect
"auto"Default. The model decides.
"required"The model calls at least one tool.
"none"The model answers without calling a tool.
{ "type": "function", "function": { "name": "get_weather" } }The model calls that tool.

A reply can call several tools at once. Set parallel_tool_calls to false for at most one call per reply.

Example

The first request offers the tool:

curl https://api.coaade.com/v1/chat/completions \
  -H "Authorization: Bearer $COAADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "coaade-mind-1",
    "messages": [{ "role": "user", "content": "What is the weather in Paris?" }],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the current weather in a city.",
          "parameters": {
            "type": "object",
            "properties": { "city": { "type": "string", "description": "The city, such as Paris" } },
            "required": ["city"]
          }
        }
      }
    ]
  }'

The reply asks for the call:

Response 200
{
  "id": "chatcmpl-8d2e…",
  "object": "chat.completion",
  "created": 1767225600,
  "model": "coaade-mind-1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_Qm3T8xVf2LhK9pW1sR4yZc6N",
            "type": "function",
            "function": { "name": "get_weather", "arguments": "{\"city\": \"Paris\"}" }
          }
        ]
      },
      "finish_reason": "tool_calls",
      "logprobs": null
    }
  ],
  "usage": { "prompt_tokens": 96, "completion_tokens": 18, "total_tokens": 114 }
}

Run the call, then send the conversation back with the assistant message and the result:

curl https://api.coaade.com/v1/chat/completions \
  -H "Authorization: Bearer $COAADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "coaade-mind-1",
    "messages": [
      { "role": "user", "content": "What is the weather in Paris?" },
      {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_Qm3T8xVf2LhK9pW1sR4yZc6N",
            "type": "function",
            "function": { "name": "get_weather", "arguments": "{\"city\": \"Paris\"}" }
          }
        ]
      },
      {
        "role": "tool",
        "tool_call_id": "call_Qm3T8xVf2LhK9pW1sR4yZc6N",
        "content": "{\"temperature_c\": 18, \"sky\": \"sunny\"}"
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the current weather in a city.",
          "parameters": {
            "type": "object",
            "properties": { "city": { "type": "string", "description": "The city, such as Paris" } },
            "required": ["city"]
          }
        }
      }
    ]
  }'

This time finish_reason is stop, and message.content holds the answer.

Streaming tool calls

With stream: true, the calls arrive in delta.tool_calls, after any answer text. Each piece has the call's index in the reply. The first piece of a call carries its id, type and function.name; its function.arguments can come in more than one piece, so join them by index. Then comes a chunk with finish_reason tool_calls, the usage chunk if you asked for it, and data: [DONE].

Send the first request of the example with "stream": true. The stream looks like this:

data: {"id":"chatcmpl-8d2e…","object":"chat.completion.chunk","created":1767225600,"model":"coaade-mind-1","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-8d2e…","object":"chat.completion.chunk","created":1767225600,"model":"coaade-mind-1","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_Qm3T8xVf2LhK9pW1sR4yZc6N","type":"function","function":{"name":"get_weather","arguments":"{\"city\": \"Paris\"}"}}]},"finish_reason":null}]}

data: {"id":"chatcmpl-8d2e…","object":"chat.completion.chunk","created":1767225600,"model":"coaade-mind-1","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]}

data: [DONE]

Tool calling errors

A tools request that fails a check gets 400 invalid_tools, with param naming the field:

{
  "error": {
    "message": "tools[0].function.name must be 1 to 64 letters, digits, underscores or dashes.",
    "type": "invalid_request_error",
    "param": "tools[0].function.name",
    "code": "invalid_tools"
  }
}

See Errors for every check.

Try tools with MCP servers in the Workbench

In the console's Workbench, you can connect your remote MCP servers and watch the model call their tools step by step. Pick a server you set up in coaade.com Settings → Plugins, or add one by its https URL, with an API key header if it needs one, or its OAuth sign-in. Coaade calls the server for you, and each call shows with its arguments, its result and how long it took.

  • By default every call waits until you click Approve or Deny. A server's read-only and destructive labels are the server's own claim, so they don't decide on their own. Turn on a server's Run tools this server marks read-only without asking switch to run the tools it marks read-only without waiting. The global Run tools without asking switch runs every call without waiting — including tools that change data — except ones the server marks destructive, which always ask.
  • A run makes up to 10 model calls and 20 tool calls in 5 minutes. One tool call has 20 seconds, and a long result is cut at 16,000 characters.
  • Runs are metered like any other Workbench run. The tool calls themselves cost nothing.
  • Header values and sign-in tokens stay encrypted with Coaade and never come back to the browser. Logs keep metadata only: never a tool's arguments or results.

This happens only in the Workbench. The API never calls an MCP server or runs a tool: Get code shows the same request with the servers' tools as function tools, and your code runs the calls the model makes, as in the tool loop.

Errors

An error response has a non-2xx status and a JSON body with an error object: a human-readable message, the error's type and a machine-readable code. An error about one field of the request also has param, naming it, such as tools[0].function.name. Branch on code.

{
  "error": {
    "message": "This API key can't call models. Turn on model access for it in your Coaade API key settings, or use a key that has it.",
    "type": "permission_error",
    "code": "model_access_disabled"
  }
}
StatuscodeWhen
401invalid_api_keyThe key is missing, malformed or unknown
403model_access_disabledThe key doesn't have the Call models permission
403model_not_in_planThe key's plan can't use this model
404model_not_foundNo such model id
400invalid_toolsA tool, tool_choice, parallel_tool_calls, an assistant message's tool_calls or a tool message is invalid. param names the field
400tools_not_supportedThe model can't call tools
400unsupported_contentA message had a non-text part (image, audio, file)
400unsupported_parametern was set to something other than 1, or the request used functions, function_call or function messages (send tools and tool messages instead)
422invalid_requestThe body failed validation (a bad field or a missing one)
422locality_claimThe system prompt told the assistant to claim it runs on the user's own device
413context_length_exceededThe conversation is too long for the model
429rate_limit_exceededA rate or fair-use limit was hit
429model_busyThe model is at capacity; retry shortly (see Retry-After)
502model_errorThe model request failed
504model_timeoutThe model took too long; for long answers, stream
503api_models_disabledModel calls over the API are turned off right now
503service_unavailableCoaade couldn't check the key or plan right now; retry

locality_claim stops a system prompt that instructs the assistant to tell end users their data never leaves their machine. Requests are processed on Coaade Cloud, so that statement would be inaccurate. Remove the claim, or describe data handling in your own privacy policy. See Errors for the full shape.

Limits

  • Per-key rate limits cap how many requests a key may send over a short window.
  • Fair-use limits apply per plan and model. Going too fast returns 429 rate_limit_exceeded.

When you're limited, wait and retry with backoff. Honor the Retry-After header when it's present. Limit numbers aren't published and may change.

To hear before a model's daily allowance runs out, turn on usage alerts: an email, or a signed webhook, at 50, 80 or 100 percent of it.

Billing is your subscription. Model calls over the API don't spend AI credits.

Privacy

Coaade routes each call through its pipeline to the model you name and returns the answer. Prompts and answers are never stored or logged.

The console's Logs page shows metadata only for each request made with a key: the time, the key, the model, the status, the latency and the token counts. It never holds a prompt, an answer or a request body, so no tool definition, tool call or tool result either.

On this page