Getting started

Documentation

APIEX.CLOUD gives you one OpenAI-compatible endpoint for dozens of AI models across every major provider. This guide covers authentication, the API reference, wallet & billing, API keys and rate limits.

The API is fully compatible with the OpenAI SDKs — point any existing OpenAI client at the base URL below and it will work without code changes.

Authentication

Every request must include your API key in the Authorization header, using the Bearer scheme.

HTTP
Authorization: Bearer YOUR_API_KEY

Never expose your API key in client-side code (browser JavaScript, mobile apps). Always call the gateway from your own backend.

Generate and manage keys from your panel: API Keys section

Quick start

Send your first request with the language of your choice. Replace YOUR_API_KEY with a key from your panel.

curl https://apiex.cloud/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello!" }
    ]
  }'
from openai import OpenAI

client = OpenAI(
    base_url="https://apiex.cloud/api/v1/",
    api_key="YOUR_API_KEY",
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)

print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://apiex.cloud/api/v1/",
  apiKey: "YOUR_API_KEY",
});

const response = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0].message.content);
$ch = curl_init( "https://apiex.cloud/api/v1/chat/completions" );

curl_setopt_array( $ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => array(
        'Authorization: Bearer YOUR_API_KEY',
        'Content-Type: application/json',
    ),
    CURLOPT_POSTFIELDS => json_encode( array(
        'model'    => 'gpt-4o-mini',
        'messages' => array(
            array( 'role' => 'user', 'content' => 'Hello!' ),
        ),
    ) ),
) );

$response = json_decode( curl_exec( $ch ), true );
echo $response['choices'][0]['message']['content'];

Errors

The API uses conventional HTTP status codes. Codes in the 2xx range indicate success; 4xx indicate a problem with the request; 5xx indicate an issue on our side.

Status Meaning
400 Bad request — a required parameter is missing or malformed.
401 Unauthorized — the API key is missing, invalid or revoked.
402 Payment required — your wallet balance is insufficient for this request.
403 Forbidden — this key is not scoped for the requested model or endpoint.
429 Too many requests — you have hit a rate limit. Back off and retry.
500 Server error — something went wrong on our side. Retrying is safe.

Error responses share a consistent JSON shape:

JSON
{
  "error": {
    "type": "insufficient_balance",
    "message": "Wallet balance is too low to complete this request.",
    "code": 402
  }
}
API reference

Base URL & endpoints

All requests are made against this base URL:

Base URL
https://apiex.cloud/api/v1/
Method Endpoint Description
POST /chat/completions Create a chat completion (streaming supported).
POST /images/generations Generate images from a text prompt.
POST /audio/speech Convert text to speech.
POST /embeddings Create vector embeddings for text.
GET /models List every model currently available to your key.

Chat completions

Creates a model response for a given conversation. Request and response shapes match the OpenAI Chat Completions API.

Request parameters

Parameter Type Description
model required string ID of the model to use. See the Models & providers section for available values.
messages required array A list of messages describing the conversation so far, each with a role and content.
temperature number Sampling temperature between 0 and 2. Higher values make output more random. Default: 1.
max_tokens integer The maximum number of tokens to generate in the response.
top_p number Nucleus sampling threshold. Usually left at the default of 1.
stream boolean If true, partial message deltas are sent as server-sent events. Default: false.

Example response

JSON
{
  "id": "chatcmpl_8k2f...",
  "object": "chat.completion",
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 10,
    "total_tokens": 19
  }
}

Streaming responses

Set "stream": true to receive the response incrementally as server-sent events, ideal for chat interfaces.

JSON
data: {"choices":[{"delta":{"content":"Hello"}}]}

data: {"choices":[{"delta":{"content":"!"}}]}

data: [DONE]

Every official OpenAI SDK handles this format automatically — no custom parsing needed on your side.

Rate limits

Rate limits protect the stability of the gateway for everyone. Limits depend on your active plan and are enforced per API key.

Every response includes headers describing your current limit status:

Header Description
X-RateLimit-LimitMaximum requests allowed in the current window.
X-RateLimit-RemainingRequests remaining in the current window.
X-RateLimit-ResetSeconds until the window resets.

When you exceed your limit, the API returns 429 Too Many Requests. Use an exponential backoff strategy before retrying.

Account

Wallet & billing

Every account has a prepaid wallet. Top it up once, then spend it across any supported model — usage is deducted per request based on tokens or units consumed.

Card top-up

Add credit to your wallet directly from your panel using a bank card.

Referral rewards

Share your referral link — both you and the person who joins receive wallet credit.

Transparent usage

Every request is logged with its exact cost, visible in your usage logs in real time.

API keys

API keys authenticate your requests and can be scoped to specific models or usage limits via key groups.

Best practices

  • Create a separate key per application or environment (production, staging, local).
  • Store keys in environment variables, never in source control.
  • Use key groups to cap spend or restrict a key to specific models.
  • Revoke a key immediately if you suspect it has been exposed.

Create an API key

Plans & subscriptions

Choose a plan for predictable monthly credit, or stay on pay-as-you-go and simply keep your wallet topped up.

No fixed plans are configured right now — every account runs on the flexible, pay-as-you-go wallet.

Resources

Models & providers

The gateway currently routes to the following providers. Call GET /models with your API key for the exact, live model list.

OpenAI OpenAI
Anthropic Anthropic
Google AI Google AI
DeepSeek DeepSeek
Zhipu AI Zhipu AI
Moonshot AI Moonshot AI
Tencent Tencent
Meta Meta

Frequently asked questions

Is the API compatible with the official OpenAI SDKs?

Yes. Simply set the SDK's base URL to the gateway endpoint and use your gateway API key — no other code changes are required.

What happens if my wallet balance runs out mid-request?

The request is rejected with a 402 Payment Required error before it is forwarded to the provider, so you are never charged for a request you could not afford.

Can I restrict a key to specific models only?

Yes, using key groups. Assign a key to a group with an allow-list of models and, optionally, its own request or spend cap.

Do unused wallet credits expire?

Wallet credit added via top-up does not expire. Credit granted as part of a time-limited plan follows that plan's duration.

Still need help?

Sign in and reach out from your panel — our team is happy to help.

Contact support