开发对接必看
Must-Read for Integration
Section titled “Must-Read for Integration”:electric_plug: Complete Function-to-Endpoint Mapping Table
Section titled “:electric_plug: Complete Function-to-Endpoint Mapping Table”| Function | Path | Full Example URL |
|---|---|---|
| Chat | /v1/chat/completions | https://api.4allapi.com/v1/chat/completions |
| Claude-style Chat | /v1/messages | https://api.4allapi.com/messages |
| Text Embeddings | /v1/embeddings | https://api.4allapi.com/v1/embeddings |
| AI Image Generation | /v1/images/generations | https://api.4allapi.com/v1/images/generations |
| Speech to Text | /v1/audio/transcriptions | https://api.4allapi.com/v1/audio/transcriptions |
| Text to Speech | /v1/audio/speech | https://api.4allapi.com/v1/audio/speech |
:test_tube: Quick Connectivity Check
Section titled “:test_tube: Quick Connectivity Check”++1) Python Example++**++
Section titled “++1) Python Example++**++”You need to first run pip install openai
Copy
import osfrom 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)++2)curl Example (Linux, Mac)++
Section titled “++2)curl Example (Linux, Mac)++”Copy the following command, replace the key inside it, then paste it into your terminal and run it
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" } ] }'
++3)curl Example (Windows)++
Section titled “++3)curl Example (Windows)++”Copy the following command, replace the key inside it, then paste it into CMD or PowerShell and run it
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\"}]}"
:blue_book:Full Integration Documentation
Section titled “:blue_book:Full Integration Documentation”Please refer to the official API docs: https://4allapi.apifox.cn
4All API Footer
Section titled “4All API Footer”4All API · One-stop AI model API aggregation platform | Pricing | Contact Us
© 2025 4All API. All rights reserved.