Skip to content
X420.ai

API Reference

API Reference

Standard OpenAI-compatible endpoint for prepaid AI API key distribution.

Base URL

https://api.x420.ai/v1

Authentication

Pass your X420.ai API key as a Bearer token in the Authorization header: Use the HTTP Authorization header with your X420.ai bearer token.

POST /v1/chat/completions

OpenAI-compatible chat completions endpoint. Requests must use a model enabled by X420.ai. Token usage is deducted from your prepaid credit and per-key cap.

POST https://api.x420.ai/v1/chat/completions
Authorization: Bearer ***
Content-Type: application/json

{
  "model": "openai/gpt-5.5",
  "messages": [{"role": "user", "content": "Hello"}],
  "max_tokens": 512,
  "stream": false
}

Request body

  • model: Required. Must be one of the models returned by GET /v1/models, for example openai/gpt-5.5.
  • messages: Required. Array of message objects with role and content.
  • stream: Optional. Set to true to receive a Server-Sent Events stream.
  • max_tokens: Optional. Hard cap on completion tokens.

Response

The response body uses the standard OpenAI-compatible chat completion format:

{
  "id": "chatcmpl_...",
  "object": "chat.completion",
  "model": "openai/gpt-5.5",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "Hello!"},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 12, "completion_tokens": 8, "total_tokens": 20}
}

Streaming

When stream: true, the response is a standard SSE stream compatible with OpenAI SDK stream helpers.

Error codes

  • 401 MISSING_API_KEY: API key missing or invalid.
  • 400 MODEL_NOT_SUPPORTED: Only GPT-5.5 is supported.
  • 402 INSUFFICIENT_BALANCE: Credit balance too low.
  • 502 UPSTREAM_ERROR: GPT-5.5 provider request failed.