API Reference
AI Gateway supports both OpenAI and Anthropic API formats. Use whichever fits your existing codebase.
OpenAI-Compatible Endpoint
POST
https://ai.hopeagrico.com/v1/chat/completionsDrop-in replacement for the OpenAI Chat Completions API. Compatible with all OpenAI SDKs and tools including Cursor, ChatBox, and ChatGPT SDK.
Supported Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Model ID (e.g., gpt-5.4-mini, auto) |
| messages | array | Required | Array of message objects with role and content |
| temperature | float | Optional | Sampling temperature (0-2). Default: 1 |
| max_tokens | integer | Optional | Maximum tokens to generate |
| top_p | float | Optional | Nucleus sampling parameter. Default: 1 |
| stream | boolean | Optional | Enable streaming responses. Default: false |
| stop | string|array | Optional | Stop sequences |
| frequency_penalty | float | Optional | Penalty for new tokens (-2 to 2). Default: 0 |
| presence_penalty | float | Optional | Penalty for presence (-2 to 2). Default: 0 |
| tools | array | Optional | Tool definitions for function calling |
| tool_choice | string|object | Optional | Tool selection strategy |
Request Example
curl -X POST https://ai.hopeagrico.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.4-mini",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7,
"max_tokens": 1000
}'Response Example
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "gpt-5.4-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 12,
"total_tokens": 37
}
}Anthropic-Compatible Endpoint
POST
https://ai.hopeagrico.com/v1/messagesNative Anthropic Messages API format. Used by Claude Code, Cline, and all Anthropic SDK apps. Supports streaming, tool use, vision, and extended thinking.
Supported Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Model ID (e.g., claude-sonnet-4.5, auto) |
| messages | array | Required | Array of message objects |
| max_tokens | integer | Required | Maximum tokens to generate |
| system | string | Optional | System prompt |
| temperature | float | Optional | Sampling temperature (0-1). Default: 1 |
| top_p | float | Optional | Nucleus sampling. Default: 1 |
| stream | boolean | Optional | Enable streaming. Default: false |
| stop_sequences | array | Optional | Stop sequences |
| tools | array | Optional | Tool definitions |
| thinking | object | Optional | Extended thinking configuration |
Request Example
curl -X POST https://ai.hopeagrico.com/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"system": "You are a helpful assistant.",
"messages": [
{"role": "user", "content": "What is the capital of France?"}
]
}'Response Example
{
"id": "msg_abc123",
"type": "message",
"model": "claude-sonnet-4.5",
"role": "assistant",
"content": [
{
"type": "text",
"text": "The capital of France is Paris."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 25,
"output_tokens": 12
}
}Error Codes
| Code | Description |
|---|---|
| 400 | Bad Request — Invalid parameters or malformed request body |
| 401 | Unauthorized — Invalid or missing API key |
| 403 | Forbidden — API key lacks required permissions or model access |
| 429 | Rate Limited — Too many requests. Retry after the Retry-After header |
| 500 | Internal Server Error — Unexpected error on our end |
| 502 | Bad Gateway — Upstream provider returned an error |
| 503 | Service Unavailable — Temporary overload or maintenance |
Rate Limiting
Rate limits are applied per account based on your subscription tier. Limits are measured as requests per hour.
| Tier | Rate Limit |
|---|---|
| Free | 10 requests/hour |
| Lite | 30 requests/hour |
| Pro | 60 requests/hour |
| Enterprise | 300 requests/hour |
When rate limited, the API returns a 429 status code with a Retry-After header indicating when you can retry.