Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cogito.decart.ai/llms.txt

Use this file to discover all available pages before exploring further.

Cogito supports OpenAI-compatible function calling on every model in the catalog. Define your tools once, and the model picks which to call, in what order, with which arguments.

Defining tools

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_current_weather",
            "description": "Get the current weather in a given city",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
                },
                "required": ["city"],
            },
        },
    }
]

Calling

response = client.chat.completions.create(
    model="gpt-oss-120b",
    messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
    tools=tools,
    tool_choice="auto",
)

tool_calls = response.choices[0].message.tool_calls
# [{ "id": "call_...", "type": "function",
#    "function": { "name": "get_current_weather",
#                  "arguments": "{\"city\": \"Tokyo\", \"unit\": \"celsius\"}" } }]

Parallel calls

Models in the catalog can issue multiple calls in one turn. The response’s tool_calls array can contain more than one entry — execute them concurrently and return all results in your next turn.
messages.append(response.choices[0].message)

for call in tool_calls:
    result = run_tool(call.function.name, json.loads(call.function.arguments))
    messages.append({
        "role": "tool",
        "tool_call_id": call.id,
        "content": json.dumps(result),
    })

final = client.chat.completions.create(
    model="gpt-oss-120b",
    messages=messages,
    tools=tools,
)

Reliability

Cogito uses grammar-constrained decoding at the inference engine level. The model can only produce token sequences that match the JSON schema of one of your declared tools — there’s no parsing fallback. Argument JSON is guaranteed valid, even on small models. If the model decides no tool is appropriate, it returns a normal text response with tool_calls: null.

Force a specific tool

tool_choice = {"type": "function", "function": {"name": "get_current_weather"}}
Useful when you want to skip the tool selection step.