agents tool calling.md

For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs; this page is available as Markdown.

Agents and Tool Calling

Build AI agents that can call functions, reason across multiple steps, and interact with external tools. Parasail supports both the Chat Completions API with tool calling and the Responses API for multi-turn agentic workflows.

Two approaches

Approach Best for API
Chat Completions + tools Single-model function calling /v1/chat/completions
Responses API Multi-turn agentic loops, parallel tool calls /v1/responses

Function calling with Chat Completions

from openai import OpenAI
import json

client = OpenAI(
    base_url="https://api.parasail.io/v1",
    api_key="<PARASAIL_API_KEY>"
)

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a city.",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string", "description": "City name"}
                },
                "required": ["city"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="parasail-deepseek-r1",
    messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
    tools=tools
)

print(response.choices[0].message.tool_calls)

Responses API (multi-turn agentic)

The Responses API supports multi-turn conversations with parallel tool calls. It uses the standard Parasail gateway:

from openai import OpenAI

client = OpenAI(
    base_url="https://api.parasail.io/v1",
    api_key="<PARASAIL_API_KEY>"
)

response = client.responses.create(
    model="parasail-kimi-k25-elicit",
    store=False,
    tools=tools,
    input=[{"role": "user", "content": "What's the weather in Tokyo?"}]
)

Relevant guides

API reference