Overview
The OpenAI Agents SDK lets you build AI agents that can automatically recommend affiliate products using ChatAds. The SDK connects to our native MCP server, so your agents get access to thechatads_message_send tool without any additional setup.
This integration uses the same MCP Server endpoint. Your ChatAds API key and quotas apply to all MCP-based integrations.
Quick Start
Step 1: Install the SDK
Step 2: Configure the MCP Connection
Step 3: Run Your Agent
chatads_message_send when users ask about products.
Configuration Options
MCPServerStreamableHttp Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | string | Required | Display name for the server |
params.url | string | Required | ChatAds MCP endpoint |
params.headers | dict | Required | Must include x-api-key |
params.timeout | int | 30 | HTTP timeout in seconds |
cache_tools_list | bool | False | Cache tool definitions for performance |
max_retry_attempts | int | 0 | Retry failed requests |
Agent Configuration
Available Tools
When connected, your agent gets access to:chatads_message_send
Analyzes user messages and returns affiliate product recommendations. Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message to analyze (1-5000 chars) |
ip | string | No | IPv4/IPv6 address for country detection (max 45 chars) |
country | string | No | ISO country code (e.g., “US”) |
quality | string | No | ”fast”, “standard” (default), or “best” |
Example: Chatbot with Affiliate Links
Error Handling
Best Practices
Cache tool lists
Set
cache_tools_list=True to avoid fetching tool definitions on every request.Set appropriate timeouts
Use 30s timeout for
thorough analysis, 15s for fast mode.Add retry logic
Set
max_retry_attempts=3 for resilience against transient failures.Monitor usage
Check your ChatAds dashboard to track API usage across all agents.
Troubleshooting
”Connection refused” or timeout
- Verify the URL is exactly:
https://api.getchatads.com/mcp/mcp - Increase the
timeoutparameter - Check your network allows outbound HTTPS
”Invalid API key” (401)
- Verify your API key starts with
cak_ - Check the key is active in your ChatAds dashboard
- Ensure the header key is
x-api-key(lowercase)
Tool not being called
- Check your agent instructions mention when to use the tool
- Verify the MCP server is in the
mcp_serverslist - Try asking explicitly: “Use chatads_message_send to find…”
Rate limit errors (429)
- Reduce request frequency
- Check your plan limits in the ChatAds dashboard
- Consider upgrading for higher quotas