gradiated

Call tools

Let a model choose an application function. Your application still validates the arguments and runs the function.

from openai import OpenAI
import os

client = OpenAI(
    base_url="https://api.gradiated.com",
    api_key=os.environ["GRADIATED_API_KEY"],
)

response = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "What is the weather in Warsaw?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a city.",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"],
            },
        },
    }],
)

tool_calls = response.choices[0].message.tool_calls

Validate the tool input before you run the function. Send the result in the next request.

Tool support depends on the selected model. Read the model catalog before you send tools.

Gradiated does not run the function. Your application controls permissions, timeouts, and side effects.