コンテンツにスキップ

开发对接必看

:electric_plug: 機能別エンドポイント対応表

Section titled “:electric_plug: 機能別エンドポイント対応表”
機能パス完全なサンプルURL
AIチャット/v1/chat/completionshttps://api.4allapi.com/v1/chat/completions
Claude形式チャット/v1/messageshttps://api.4allapi.com/messages
テキスト埋め込み/v1/embeddingshttps://api.4allapi.com/v1/embeddings
AI画像生成/v1/images/generationshttps://api.4allapi.com/v1/images/generations
音声からテキストへ/v1/audio/transcriptionshttps://api.4allapi.com/v1/audio/transcriptions
テキストから音声へ/v1/audio/speechhttps://api.4allapi.com/v1/audio/speech

:test_tube: 接続確認をすばやく行う

Section titled “:test_tube: 接続確認をすばやく行う”

先に pip install openai を実行してください

コピー

import os
from openai import OpenAI
client = OpenAI(
# 環境変数を設定していない場合は、4All APIで購入・交換したAPI Key(密钥)を使って、次の行を 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", # モデル名は、購入したAPI Keyで利用可能なモデル名を使ってテストしてください。そうしないと別のモデルが呼び出されます。4All APIの一部プランは全モデル利用可ですが、一部は利用可能モデルが制限されています。サイト上に表示されている名前と完全に一致している必要があります。
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你是谁?"},
],
stream=True
)
for chunk in completion:
print(chunk.choices[0].delta.content, end="", flush=True)

++2)curl サンプル(Linux、Mac OS)++

Section titled “++2)curl サンプル(Linux、Mac OS)++”

以下のコマンドをコピーし、key を置き換えてから、OSのターミナルに貼り付けて実行してください

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

以下のコマンドをコピーし、key を置き換えてから、CMD または PowerShell のターミナルに貼り付けて実行してください

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

:blue_book:完全な接続ドキュメント

Section titled “:blue_book:完全な接続ドキュメント”

公式APIドキュメントをご覧ください: https://4allapi.apifox.cn


4All API · ワンストップAI大規模モデルAPI統合プラットフォーム | 料金 | お問い合わせ

© 2025 4All API. All rights reserved.