Using the API

User Guide

Using the API

Replace OpenAI's base_url with the platform URL and use your platform token as api_key to start calling.

Replace OpenAI's `base_url` with the platform URL and use your platform token as `api_key` to start calling. Production paths are `/v1/*`; the online Playground uses `/pg/chat/completions` for debugging, which differs from the production API path.

Playground online test

The Playground is a built-in online tool to chat with models without writing code—ideal for quickly verifying your token.

Open the Playground

  1. In the top nav go to Demo → Chat Demo, or visit /demo/chat
  2. On Token Management , click Chat on a token to enter the Playground with that token

Use the Playground

  1. On the left, choose text / image / video mode, group, and model (when opened from a token page, available models are restricted)
  2. Type a message in the input at the bottom and click Send
  3. The conversation area shows the model reply
easyapi.com/demo/chat
Hi, introduce EasyAPI in one sentence.
EasyAPI is an OpenAI-compatible AI gateway that unifies multiple model providers with token and quota management.
Type a message…Send

Playground preview: pick a model on the left, chat in the center, inspect request/response on the right (layout is illustrative)

Get API address

The default API address is https://token.easyapi.com. You can override it at deploy time with the NUXT_PUBLIC_API_BASE_URL env var; OpenAI SDK base_url must append /v1.

Copy API address

  1. Check the request URL generated for the current site in the code-example Playground panel
  2. Or confirm NUXT_PUBLIC_API_BASE_URL in your deployment environment / admin docs
  3. For production calls use as the OpenAI-compatible base_url

OpenAI-compatible Base URL

https://token.easyapi.com/v1

Configure client

Paste the copied URL as base_url in your client or code, together with your platform token as api_key to start calling.

  • HTTP header: Authorization: Bearer YOUR_API_KEY
  • Token Management Chat menu can import Lobe Chat, OpenCat, etc. with the API base URL pre-filled
  • See API authenticationfor full auth details

Code examples

Addresses below match the current site config; replace sk-xxxxxxxx with your real token.

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxxxxxxxxxx",  # Platform-issued token
    base_url="https://token.easyapi.com/v1"
)

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

Claude native format

curl https://token.easyapi.com/v1/messages \
  -H "x-api-key: sk-xxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model": "claude-3-5-sonnet-20241022", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

Gemini native format

curl "https://token.easyapi.com/v1beta/models/gemini-1.5-pro:generateContent?key=sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"contents": [{"parts": [{"text": "Hello"}]}]}'

Supported API endpoints

EasyAPI exposes OpenAI-compatible REST endpoints; whether a model supports an endpoint depends on backend channel configuration.

APIPathDescription
Chat completionsPOST /v1/chat/completionsDialogue generation with streaming support
Text completionsPOST /v1/completionsLegacy completions API
EmbeddingsPOST /v1/embeddingsText vectorization
Image generationPOST /v1/images/generationsText-to-image
Image editsPOST /v1/images/editsImage editing
Speech-to-textPOST /v1/audio/transcriptionsWhisper, etc.
Text-to-speechPOST /v1/audio/speechTTS
RerankPOST /v1/rerankDocument reranking
Responses APIPOST /v1/responsesOpenAI Responses format
RealtimeGET /v1/realtime(WebSocket)OpenAI Realtime API
Model listGET /v1/modelsList available models