API Reference
A I Gateway
OpenAI-compatible AI endpoints
POST
/v1/chat/completionsChat Completions (OpenAI-compatible)
OpenAI-compatible chat completions endpoint with automatic X402 payments.
Just change your base URL and use your AgnicPay token!
Auth:ApiTokenOAuth2
Request body *
| Field | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| model* | string | Model identifier (e.g., openai/gpt-4o, anthropic/claude-3.5-sonnet) | |||||||||
| messages* | object[] | show nested schemaarray of
| |||||||||
| temperature | number | ||||||||||
| max_tokens | integer | ||||||||||
| stream | boolean |
Example request
{
"model": "openai/gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}Responses
200Chat completion response
| Field | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | string | ||||||||||||||||||||||
| object | string | example: "chat.completion" | |||||||||||||||||||||
| created | integer | ||||||||||||||||||||||
| model | string | ||||||||||||||||||||||
| choices | object[] | show nested schemaarray of
| |||||||||||||||||||||
| usage | object | show nested schema
|
401Unauthorized - invalid or missing authentication
| Field | Type | Description |
|---|---|---|
| error | string | |
| error_description | string | |
| message | string |
402Payment required or spending limit exceeded
Example (cURL)
curl -X POST 'https://api.agnic.ai/v1/chat/completions' \
-H 'X-Agnic-Token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"model":"openai/gpt-4o","messages":[{"role":"user","content":"Hello!"}]}'GET
/v1/modelsList Available Models
List all available AI models through the gateway.
Auth:ApiTokenOAuth2
Responses
200Models listed successfully
| Field | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| object | string | example: "list" | |||||||||||||||
| data | object[] | show nested schemaarray of
|
Example (cURL)
curl -X GET 'https://api.agnic.ai/v1/models' \
-H 'X-Agnic-Token: YOUR_TOKEN'