Base URL

All API requests use the base URL:
https://api.redpill.ai/v1

Authentication

Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Get API Key

Learn about authentication →

Available Endpoints

Chat & Completions

EndpointMethodDescription
/v1/chat/completionsPOSTCreate chat completion (recommended)
/v1/completionsPOSTCreate text completion (legacy)

Embeddings

EndpointMethodDescription
/v1/embeddingsPOSTCreate text embeddings

Models

EndpointMethodDescription
/v1/modelsGETList all 218+ models
/v1/models/phalaGETList Phala confidential models

TEE Verification

EndpointMethodDescription
/v1/attestation/reportGETGet TEE attestation report
/v1/signature/{request_id}GETGet request signature

Request Format

All POST requests use JSON:
curl https://api.redpill.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "Hello"}]
  }"

Response Format

Successful responses return JSON with 200 status:
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "openai/gpt-4o",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! How can I help you?"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

Error Responses

Errors return appropriate HTTP status codes:
{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

Common Status Codes

CodeMeaning
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Insufficient credits
404Not Found - Endpoint or model doesn’t exist
429Rate Limit Exceeded
500Server Error
503Service Unavailable

Error Handling

Learn how to handle errors →

Rate Limits

Rate limits are based on your account tier:
TierRequests/MinTokens/Min
Free60100,000
Pro6001,000,000
EnterpriseCustomCustom
Rate limit headers are included in responses:
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 599
X-RateLimit-Reset: 1677652348

OpenAI Compatibility

RedPill is fully compatible with OpenAI SDKs:
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_REDPILL_KEY",
    base_url="https://api.redpill.ai/v1"
)

# All OpenAI SDK methods work!
response = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[{"role": "user", "content": "Hello"}]
)

Custom Headers

RedPill supports optional custom headers:
HeaderDescriptionExample
x-redpill-providerForce specific provideropenai
x-redpill-trace-idCustom trace IDmy-trace-123
x-redpill-metadataCustom metadata (JSON){"user_id": "123"}
Example:
curl https://api.redpill.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-redpill-provider: anthropic" \
  -H "x-redpill-trace-id: request-abc-123" \
  -d '{...}"

Streaming

Enable streaming for real-time responses:
curl https://api.redpill.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "Write a story"}],
    "stream": true
  }"

Streaming Guide

Learn about streaming responses →

SDK Support

RedPill works with official OpenAI SDKs:
  • ✅ Python SDK (openai)
  • ✅ JavaScript/TypeScript SDK (openai)
  • ✅ Go SDK (go-openai)
  • ✅ Ruby SDK (ruby-openai)
  • ✅ Java SDK (openai-java)
  • ✅ .NET SDK (Azure.AI.OpenAI)

API Endpoints