Skip to content

Using the API & Playground

The playground is for quick online testing of AI models: enter a question or an instruction, chat with the model and inspect the result. Open it from Playground in the left navigation, or at /playground.

  1. Choose a group and model: pick an available model group and a specific model below the input box to confirm which model this conversation uses.
  2. Set request parameters: click the parameter button to enable and adjust generation parameters such as temperature, top P, frequency penalty, presence penalty and max tokens.
  3. Write the prompt: type your question, instruction or prompt in the input box at the bottom.
  4. Send the request: once the model, parameters and input look right, click Send.
  5. Read the reply: when generation finishes, read the response in the conversation area and keep typing to continue a multi-turn conversation.

The gateway’s OpenAI-compatible address is usually:

https://your-host/v1

Use an API key as the bearer token:

Authorization: Bearer sk-your-api-key

For chat completions:

终端窗口
curl https://your-host/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxx",
base_url="https://your-host/v1",
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
终端窗口
curl https://your-host/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"}]}'
终端窗口
curl "https://your-host/v1beta/models/gemini-1.5-pro:generateContent?key=sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"contents": [{"parts": [{"text": "Hello"}]}]}'
Endpoint Path Description
Chat completions POST /v1/chat/completions OpenAI Chat Completions compatible endpoint. Requires model and messages, and supports streaming or normal responses.
Playground chat POST /pg/chat/completions Dedicated endpoint for the web playground. Authenticates with your sign-in session instead of an API key; billing works exactly as it does for normal calls.
Text completions POST /v1/completions Legacy text completion endpoint. Requires prompt and model.
Responses API POST /v1/responses OpenAI Responses format endpoint, supporting input, tools and response events.
Responses compaction POST /v1/responses/compact Compacts the context of a Responses request.
Claude Messages POST /v1/messages Anthropic Claude Messages compatible endpoint. Requires model and message content, converted to the upstream protocol where needed.
Codex web search POST /v1/alpha/search Standalone Codex web search format, supported by a subset of models only.
Realtime conversation GET /v1/realtime (WebSocket) OpenAI Realtime style bidirectional endpoint. The model is usually passed as a query parameter, and the API key can be passed as a bearer token or a WebSocket subprotocol.
Endpoint Path Description
Embeddings POST /v1/embeddings Converts text or an array of text into vectors. Requires input.
Gemini-compatible embeddings POST /v1/engines/{model}/embeddings Legacy Gemini-style embedding path that takes the model name from the URL.
Rerank POST /v1/rerank Sorts candidate documents by relevance to a query. The query and the document list must not be empty.
Moderation POST /v1/moderations Runs content moderation over text or other input. When no model is given, a default moderation model candidate is used.
Endpoint Path Description
Image generation POST /v1/images/generations Generates images from a prompt. The available sizes, quality levels and counts depend on the model you pick.
Image editing POST /v1/images/edits Edits an image from an input image and a prompt. Supports JSON and multipart/form-data requests.
Legacy edit endpoint POST /v1/edits A retained compatibility path that enters the image relay. New clients should prefer /v1/images/edits.
Speech to text POST /v1/audio/transcriptions Transcribes audio, forwarded to the matching speech recognition channel in the OpenAI audio format.
Audio translation POST /v1/audio/translations Recognizes audio content and returns the translated text.
Text to speech POST /v1/audio/speech Converts input text into audio.

Async generation endpoints for video, music and similar are covered under “Async generation and task endpoints” in Logs & Async Tasks.

Endpoint Path Description
Model list GET /v1/models Returns the OpenAI-format model list by default. Anthropic headers return the Claude format, and an x-goog-api-key header or key query parameter returns the Gemini format.
Model details GET /v1/models/{model} Returns information about one model, or a model_not_found error object if it does not exist.
Gemini model list GET /v1beta/models Returns the available models in the Gemini format, with models and nextPageToken response fields.
OpenAI-format model list GET /v1beta/openai/models Returns the model list in the OpenAI format under the Gemini-compatible namespace.
Endpoint Path Description
Native Gemini model call POST /v1beta/models/{model}:{action} Native Gemini format endpoint supporting generateContent, streamGenerateContent and embedding operations.
Gemini-compatible model call POST /v1/models/{model}:{action} Accepts Gemini-style model operations under the /v1 prefix, parsed and converted by the Gemini relay.