Skip to content

curl

In these examples sk-xxxx stands for your token and YOUR_MODEL for a model on the pricing page that is available in your group. Put the token in an environment variable first, so it does not end up in your shell history:

终端窗口
export OPENPALMLAB_API_KEY=sk-xxxx
终端窗口
curl https://api.openpalm.ai/v1/chat/completions \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'
终端窗口
curl https://api.openpalm.ai/v1/responses \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"input": "Hello"
}'
终端窗口
curl https://api.openpalm.ai/v1/messages \
-H "x-api-key: $OPENPALMLAB_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello"}]
}'
终端窗口
curl "https://api.openpalm.ai/v1beta/models/YOUR_MODEL:generateContent" \
-H "x-goog-api-key: $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Hello"}]}]
}'
终端窗口
curl https://api.openpalm.ai/v1/embeddings \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_EMBEDDING_MODEL",
"input": "The quick brown fox"
}'
终端窗口
curl https://api.openpalm.ai/v1/images/generations \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_IMAGE_MODEL",
"prompt": "A watercolor painting of a lighthouse at dawn",
"size": "1024x1024"
}'

Whether size, n, quality and similar fields take effect depends on the model; write the body in the OpenAI images format. Whether the image comes back as a link or as base64 also depends on the model and channel.

终端窗口
curl https://api.openpalm.ai/v1/audio/speech \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_TTS_MODEL",
"input": "Hello, welcome to OpenPalmLab.",
"voice": "alloy"
}' \
--output speech.mp3

Which voices are available depends on the model.

终端窗口
curl https://api.openpalm.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-F model=YOUR_STT_MODEL \

This endpoint takes a file as multipart/form-data; do not add a Content-Type header yourself.

终端窗口
curl https://api.openpalm.ai/v1/rerank \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_RERANK_MODEL",
"query": "What is a vector database?",
"documents": ["A vector database stores and searches vectors.", "The weather is nice today."],
"top_n": 1
}'

The image, audio and rerank endpoints above need a model and channel of that type in your group. Availability depends on what the site has enabled; filter the pricing page by endpoint type to check.

终端窗口
curl https://api.openpalm.ai/v1/models \
-H "Authorization: Bearer $OPENPALMLAB_API_KEY"

Command-line clients: Claude Code, Codex CLI, Gemini CLI, OpenCode. Web chat: OpenPalm Chat.