API Reference

ApexApi follows the OpenAI API format. All endpoints use the base URL https://api.apexapi.dev/v1.

Authentication

All API requests require a valid API key passed in the Authorization header.

Authorization: Bearer ak-your-api-key

API keys start with ak- and are 48 characters long. Create keys in your dashboard.

Chat Completions

Create a chat completion with the specified model. Supports streaming via Server-Sent Events.

POST/v1/chat/completions

Parameters

modelstringrequired

Model ID in provider/model format (e.g., openai/gpt-4o).

messagesarrayrequired

Array of message objects with role and content fields. Content can be a string or an array of multimodal parts. See Images & PDFs in Chat.

temperaturenumber

Sampling temperature between 0 and 2. Defaults to 1.

max_tokensinteger

Maximum number of tokens to generate.

streamboolean

If true, responses are streamed via Server-Sent Events. Defaults to false.

top_pnumber

Nucleus sampling parameter. Defaults to 1.

stopstring | array

Stop sequences. Up to 4 sequences.

Request

Request
POST https://api.apexapi.dev/v1/chat/completions
Authorization: Bearer ak-your-api-key
Content-Type: application/json

{
  "model": "openai/gpt-4o",
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "What is the capital of France?" }
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "stream": false
}

Response

Response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1710000000,
  "model": "openai/gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The capital of France is Paris."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 8,
    "total_tokens": 33
  }
}

Images & PDFs in Chat

Chat completions accept multimodal content. Instead of a string, a message's content can be an array of parts. It's the same format as the OpenAI API, so existing SDKs work unchanged. The playground supports both via the attach button.

Content part types

textobject

A text segment: { "type": "text", "text": "..." }.

image_urlobject

An image, for vision-capable models. Accepts a base64 data URI or a publicly reachable HTTPS URL: { "type": "image_url", "image_url": { "url": "..." } }. Optional detail: low | high | auto.

fileobject

A PDF document, for PDF-capable models. Must be a base64 application/pdf data URI, max 2 MB per file and 4 file parts per request.

Model support

Images work on all vision-capable models. PDFs are supported on Anthropic Claude, OpenAI GPT-4o / GPT-4.1 / o-series, and Google Gemini models. Sending a PDF to a model without PDF support returns 400 with error code unsupported_content.

Attachments are billed as input tokens by the upstream provider, roughly 1,000–1,600 tokens per image and 1,500–3,000 tokens per PDF page. They are processed in transit only and never stored by ApexApi.

Vision request

Request (image)
POST https://api.apexapi.dev/v1/chat/completions
Authorization: Bearer ak-your-api-key
Content-Type: application/json

{
  "model": "anthropic/claude-sonnet-4.6",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "What is in this image?" },
        {
          "type": "image_url",
          "image_url": { "url": "data:image/jpeg;base64,/9j/4AAQ..." }
        }
      ]
    }
  ]
}

PDF request

Request (PDF document)
POST https://api.apexapi.dev/v1/chat/completions
Authorization: Bearer ak-your-api-key
Content-Type: application/json

{
  "model": "openai/gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "Summarize this document." },
        {
          "type": "file",
          "file": {
            "filename": "report.pdf",
            "file_data": "data:application/pdf;base64,JVBERi0xLjQ..."
          }
        }
      ]
    }
  ]
}

Image Generation

Generate images from text prompts using supported image models.

POST/v1/images/generations

Parameters

modelstringrequired

Image model ID (e.g., openai/gpt-image-2, google/nano-banana-2). Full list via GET /v1/models.

promptstringrequired

Text description of the image to generate (max 4,000 characters).

ninteger

Number of images to generate, 1–10. Defaults to 1.

sizestring

Image size as WIDTHxHEIGHT, e.g. 1024x1024 (default).

qualitystring

Image quality. standard (default) or hd.

response_formatstring

url (default) or b64_json.

Request

Request
POST https://api.apexapi.dev/v1/images/generations
Authorization: Bearer ak-your-api-key
Content-Type: application/json

{
  "model": "openai/gpt-image-2",
  "prompt": "A serene mountain landscape at sunset",
  "n": 1,
  "size": "1024x1024",
  "quality": "standard"
}

Response

Response
{
  "created": 1710000000,
  "data": [
    {
      "url": "https://uploads.apexapi.dev/generated/req-id-0.png"
    }
  ]
}

The url is always a hosted HTTPS link (never inline base64), whichever model serves the request. Links are temporary. Download the image promptly rather than hotlinking.

Video Generation

Generate video from a text prompt (and optionally a starting image) using supported video models like Veo, Kling, Seedance, Hailuo, and Grok Imagine. Video generation is asynchronous: you submit a job and get an id, then poll until it's done (renders take minutes).

POST/v1/videos/generations

Parameters

modelstringrequired

Video model ID (e.g., google/veo3.1/lite, bytedance/seedance-2.0/text-to-video). Full list via GET /v1/models (filter type=video).

promptstringrequired

Text description of the video to generate.

durationinteger

Clip length in seconds. Allowed values are model-specific, e.g. Veo accepts 4, 6, or 8; Seedance accepts 415. An unsupported value returns 400 with the allowed set. Omit to use the model's default.

resolutionstring

480p, 720p (default), 1080p, 2k, or 4k (model-dependent).

aspect_ratiostring

e.g. 16:9, 9:16, 1:1.

image_urlstring

Starting-frame image URL for image-to-video models.

Submit

Request
POST https://api.apexapi.dev/v1/videos/generations
Authorization: Bearer ak-your-api-key
Content-Type: application/json

{
  "model": "google/veo3.1/lite",
  "prompt": "A calm ocean wave rolling onto a sandy beach at sunset",
  "duration": 4,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}
Response (202 Accepted)
{
  "id": "a5933807-c44f-4eec-b25a-15f27a19b9ea",
  "status": "queued"
}

Poll for the result

Poll GET /v1/videos/generations/{id}
GET https://api.apexapi.dev/v1/videos/generations/a5933807-...
Authorization: Bearer ak-your-api-key

# while rendering (poll every few seconds — takes minutes):
{ "id": "a5933807-...", "status": "processing" }

# when finished:
{ "id": "a5933807-...", "status": "completed", "url": "https://.../video.mp4" }

# on failure (the pre-auth hold is released — you are not charged):
{ "id": "a5933807-...", "status": "failed", "error": "..." }

You're billed per second of generated video, matching the duration you requested. A job that fails releases its hold. You are not charged for a video you didn't get.

Audio (Text-to-Speech)

Generate natural voiceover from text using ElevenLabs models. Returns a URL to an MP3 file. Billed per 1,000 characters.

POST/v1/audio/speech

Parameters

modelstringrequired

Audio model ID (e.g., elevenlabs/tts/multilingual-v2).

inputstringrequired

The text to synthesize into speech (1–10,000 characters).

voicestring

Optional ElevenLabs voice name or id. Leave empty for the model default voice.

Request

Request
POST https://api.apexapi.dev/v1/audio/speech
Authorization: Bearer ak-your-api-key
Content-Type: application/json

{
  "model": "elevenlabs/tts/multilingual-v2",
  "input": "Welcome to ApexAPI — one API for every AI model.",
  "voice": "Rachel"
}

Response

Response
{
  "created": 1710000000,
  "data": [
    { "url": "https://.../output.mp3" }
  ]
}

List Models

Retrieve a list of all available models and their pricing.

GET/v1/models

Response

Response
{
  "object": "list",
  "data": [
    {
      "id": "openai/gpt-4o",
      "object": "model",
      "created": 1710000000,
      "owned_by": "openai",
      "pricing": {
        "prompt": "0.0025",
        "completion": "0.01"
      }
    }
  ]
}

Context for AI (web data)

Give models live web knowledge on the same key and balance. Billed per unit; failures are free. Full guides: read a page, read a site, structured extract.

POST/v1/scrape(URL → markdown)
Read a page
curl https://api.apexapi.dev/v1/scrape \
  -H "Authorization: Bearer ak-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/pricing", "stealth": "auto" }'
# → { "content": "# Pricing…", "tier": "standard", "cost": 0.002, … }
POST/v1/crawl(site → markdown, async)
Read a site
curl https://api.apexapi.dev/v1/crawl \
  -H "Authorization: Bearer ak-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://docs.example.com", "limit": 200 }'
# → { "id": "…", "status": "running" }  then poll GET /v1/crawl/{id}
POST/v1/extract(structured JSON, async)
Structured extract
curl https://api.apexapi.dev/v1/extract \
  -H "Authorization: Bearer ak-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{ "scraper": "amazon-product",
        "input": { "url": "https://www.amazon.com/dp/B09B8V1LZ3" } }'
# → { "id": "…", "status": "running" }  then poll GET /v1/extract/{id}
# List scrapers: GET /v1/extract/scrapers