Venice AI
Access 75+ Venice AI models through the Cluster Protocol unified API
Quick Start
Make your first Venice AI request through Cluster Protocol in seconds. The API is OpenAI-compatible — use any existing OpenAI SDK by changing the base URL.
curl -X POST https://api.clusterprotocol.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "llama-3.3-70b",
"provider": "venice",
"messages": [
{"role": "user", "content": "Hello from Venice AI!"}
]
}'Authentication
Two authentication methods are available. Use an API key for standard access, or leverage x402 for permissionless, pay-per-request access with USDC.
Method 1: API Key
Include your API key in the Authorization header.
Authorization: Bearer YOUR_API_KEY
Method 2: x402 (No API Key)
Send requests without an API key. The server responds with HTTP 402 and a payment-required header containing payment details. Pay with USDC on Base (chain 8453) and re-submit with the payment proof.
Chat Completions
Generate text responses from Venice AI models. Compatible with the OpenAI chat completions format.
/v1/chat/completionsParameters
| Parameter | Type | Description |
|---|---|---|
| modelrequired | string | Model ID from the Venice catalog |
| providerrequired | string | Set to "venice" |
| messagesrequired | array | Array of message objects with role and content |
| stream | boolean | Enable SSE streaming (default: false) |
| max_tokens | integer | Maximum tokens to generate |
| temperature | number | Sampling temperature (0-2, default: 1) |
Example Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "llama-3.3-70b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21
}
}Image Generation
Generate images using Venice AI image models through Cluster Protocol.
/v1/images/generationsParameters
| Parameter | Type | Description |
|---|---|---|
| modelrequired | string | Image model ID |
| providerrequired | string | Set to "venice" |
| promptrequired | string | Text description of the desired image |
| n | integer | Number of images to generate (1-4) |
| size | string | Image dimensions (e.g. "1024x1024") |
curl -X POST https://api.clusterprotocol.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "fluently-xl",
"provider": "venice",
"prompt": "A futuristic city skyline at sunset",
"n": 1,
"size": "1024x1024"
}'Model Catalog
Venice AI provides access to 75+ models across multiple categories. Set the model parameter to any model ID below.
x402 Payment Integration
The x402 protocol enables permissionless API access without pre-registration. Send a request without an API key, receive payment instructions, pay with USDC, and re-submit with proof.
Flow
payment-required header (base64 JSON)Example: Handling 402 Response
const response = await fetch("https://api.clusterprotocol.ai/v1/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "llama-3.3-70b",
provider: "venice",
messages: [{ role: "user", content: "Hello!" }],
}),
});
if (response.status === 402) {
const paymentHeader = response.headers.get("payment-required");
const paymentInfo = JSON.parse(atob(paymentHeader!));
// paymentInfo contains:
// - recipient: USDC recipient address
// - amount: amount in USDC (e.g. "0.003")
// - chain: 8453 (Base)
// - token: USDC contract address
// Execute payment on Base, then re-submit with proof
}Streaming
Enable real-time token streaming via Server-Sent Events (SSE) by setting stream: true. Each chunk contains a delta of the response.
curl -X POST https://api.clusterprotocol.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "llama-3.3-70b",
"provider": "venice",
"messages": [{"role": "user", "content": "Write a haiku"}],
"stream": true
}'SSE Format
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" world"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Error Handling
The API returns standard HTTP status codes. Error responses include a JSON body with details about what went wrong.
| Status | Meaning | Action |
|---|---|---|
| 400 | Bad Request | Check request body and parameters |
| 401 | Unauthorized | Verify your API key |
| 402 | Payment Required | Complete x402 payment or add funds |
| 404 | Not Found | Verify model ID and endpoint path |
| 429 | Rate Limited | Back off and retry with exponential delay |
| 500 | Server Error | Retry after a brief delay |
| 503 | Model Unavailable | The model is temporarily offline; try another |
Error Response Format
{
"error": {
"message": "Invalid model ID: unknown-model",
"type": "invalid_request_error",
"code": "model_not_found"
}
}