API Overview

External API authentication, models, chat completions, image generation, and credits.

Base URL

Use your site origin as the API base URL.

https://your-domain.com/api/v1

Authentication

Create an API key in Settings -> API Keys, then send it as a bearer token:

Authorization: Bearer sk_live_...

API keys are shown only once when created. The platform stores only the hashed value and a short prefix.

Available Models

List the currently enabled public models:

curl https://your-domain.com/api/v1/models \
  -H "Authorization: Bearer $YOUR_API_KEY"

Example response:

{
  "object": "list",
  "data": [
    {
      "id": "openai/gpt-5",
      "object": "model",
      "owned_by": "openrouter",
      "display_name": "GPT-5",
      "category": "chat",
      "capabilities": ["chat", "reasoning"],
      "credit_cost": 3
    }
  ]
}

Chat Completions

Endpoint:

POST /api/v1/chat/completions

Request:

curl https://your-domain.com/api/v1/chat/completions \
  -H "Authorization: Bearer $YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5",
    "messages": [
      { "role": "user", "content": "Write a haiku about APIs." }
    ]
  }'

Node.js example:

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.YOUR_API_KEY,
  baseURL: 'https://your-domain.com/api/v1',
});

const completion = await client.chat.completions.create({
  model: 'openai/gpt-5',
  messages: [{ role: 'user', content: 'Write a haiku about APIs.' }],
});

console.log(completion.choices[0]?.message?.content);

The chat endpoint enforces the platform model whitelist before routing the request upstream.

Image Generation

Endpoint:

POST /api/v1/images/generations

Request:

curl https://your-domain.com/api/v1/images/generations \
  -H "Authorization: Bearer $YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/nano-banana-pro",
    "prompt": "A cinematic photo of a robot reading API docs",
    "size": "1024x1024"
  }'

Response:

{
  "created": 1710000000,
  "data": [],
  "task_id": "local-task-id",
  "provider_task_id": "provider-task-id",
  "status": "pending",
  "model": "google/nano-banana-pro"
}

The first version returns task metadata immediately. Generated assets continue through the platform task pipeline.

Credits And Limits

  • Chat and image requests consume platform credits.
  • Credit cost is defined per model in the platform model registry.
  • The request is rejected before execution when the current user balance is insufficient.
  • API keys also carry a per-minute rate limit field for future enforcement.

Error Format

All /api/v1/* endpoints return a consistent error body:

{
  "error": {
    "message": "Model is not available",
    "type": "model_not_available",
    "code": "model_not_available"
  }
}

Common error codes:

  • invalid_api_key
  • api_disabled
  • model_required
  • model_not_available
  • messages_required
  • prompt_required
  • insufficient_credits
  • provider_not_configured
  • provider_error

Notes

  • Only models exposed by the platform model registry can be used.
  • API request logs are recorded with request ID, key, model, status, latency, and credit cost.
  • Videos and music are not part of the public API in this version.