Overview
The Agent API provides tools that extend model capabilities beyond their training data. Tools must be explicitly configured in your API request—once enabled, models autonomously decide when to use them based on your instructions.
Enable tools by adding them to the
tools array in your request:
Web Search Tool
Theweb_search tool allows models to perform web searches with advanced filtering capabilities. Use it when you need current information, news, or data beyond the model’s training cutoff.
Pricing: $5.00 per 1,000 search calls ($0.005 per search), plus token costs.
Example
Key Parameters
Fetch URL Tool
Thefetch_url tool fetches and extracts content from specific URLs. Use it when you need the full content of a particular web page, article, or document rather than search results.
Pricing: $0.50 per 1,000 requests ($0.0005 per fetch), plus token costs.
Example
When to Use
Function Calling
Function calling allows you to define custom functions that models can invoke during a conversation. Unlike built-in tools, custom functions let you connect the model to your own systems—databases, APIs, business logic, or any external service. Pricing: No additional cost (standard token pricing applies).How It Works
Function calling follows a multi-turn conversation pattern:- Define functions with names, descriptions, and parameter schemas
- Send your prompt with function definitions
- Model returns a
function_callitem if it needs to call a function - Execute the function in your code
- Return results as a
function_call_outputitem - Model uses the results to generate its final response
Example
Key Properties
Next Steps
Agent API Quickstart
Get started with the Agent API.
Models
Explore direct model selection and third-party models.
API Reference
View complete endpoint documentation.
Output Control
Configure streaming responses and structured outputs with JSON schema.