Skip to content

开发对接必看

:electric_plug: Complete Function-to-Endpoint Mapping Table

Section titled “:electric_plug: Complete Function-to-Endpoint Mapping Table”
FunctionPathFull Example URL
Chat/v1/chat/completionshttps://api.4allapi.com/v1/chat/completions
Claude-style Chat/v1/messageshttps://api.4allapi.com/messages
Text Embeddings/v1/embeddingshttps://api.4allapi.com/v1/embeddings
AI Image Generation/v1/images/generationshttps://api.4allapi.com/v1/images/generations
Speech to Text/v1/audio/transcriptionshttps://api.4allapi.com/v1/audio/transcriptions
Text to Speech/v1/audio/speechhttps://api.4allapi.com/v1/audio/speech

You need to first run pip install openai

Copy

import os
from openai import OpenAI
client = OpenAI(
# If you have not set an environment variable, replace the following line with the API Key you purchased and redeemed from 4All API: api_key="sk-xxx",
api_key=os.getenv("API_KEY"),
base_url="https://api.4allapi.com/v1",
)
completion = client.chat.completions.create(
model="qwen3-max", # Please use a model name permitted by your purchased API Key for testing; otherwise, it may switch to a different one. Some 4All API plans include access to all models, while others restrict certain models. Make sure the name exactly matches what is shown on the website.
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
stream=True
)
for chunk in completion:
print(chunk.choices[0].delta.content, end="", flush=True)

Copy the following command, replace the key inside it, then paste it into your terminal and run it

Terminal window
curl --request POST \
--url https://api.4allapi.com/v1/chat/completions \
--header 'Authorization: Bearer sk-replace-with-your-key' \
-H "Content-Type: application/json" \
--data '{
"model": "qwen-plus",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'

Copy the following command, replace the key inside it, then paste it into CMD or PowerShell and run it

Terminal window
curl https://api.4allapi.com/v1/chat/completions ^
-H "Content-Type: application/json" ^
-H "Authorization: Bearer sk-replace-with-your-key" ^
-d "{\"model\": \"qwen-plus\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}]}"

Please refer to the official API docs: https://4allapi.apifox.cn


4All API · One-stop AI model API aggregation platform | Pricing | Contact Us

© 2025 4All API. All rights reserved.