import os
from openai import OpenAI
client = OpenAI( api_key=os.getenv("ATLASCLOUD_API_KEY"), base_url="https://api.atlascloud.ai/v1")response = client.chat.completions.create( model="bytedance/doubao-seed-2.0-lite-260428", messages=[{"role":"user","content":"what is difference between http and https"}], max_tokens=65536, temperature=0.7)print(response.choices[0].message.content)
インストール
お使いの言語に必要なパッケージをインストールしてください。
bash
pip install requests
認証
すべての API リクエストには API キーによる認証が必要です。API キーは Atlas Cloud ダッシュボードから取得できます。
bash
exportATLASCLOUD_API_KEY="your-api-key-here"
HTTP ヘッダー
python
import os
API_KEY = os.environ.get("ATLASCLOUD_API_KEY")headers ={"Content-Type":"application/json","Authorization":f"Bearer {API_KEY}"}
API キーを安全に保管してください
API キーをクライアントサイドのコードや公開リポジトリに公開しないでください。代わりに環境変数またはバックエンドプロキシを使用してください。
リクエストを送信
import requests
url ="https://api.atlascloud.ai/v1/chat/completions"headers ={"Content-Type":"application/json","Authorization":"Bearer $ATLASCLOUD_API_KEY"}data ={"model":"bytedance/doubao-seed-2.0-lite-260428","messages":[{"role":"user","content":"what is difference between http and https"}],"max_tokens":65536,"temperature":0.7,"stream":False}response = requests.post(url, headers=headers, json=data)print(response.json())
入力 Schema
以下のパラメータがリクエストボディで使用できます。
合計: 5必須: 2任意: 3
modelstringrequired
The model ID to use for the completion.
Example: "bytedance/doubao-seed-2.0-lite-260428"
messagesarray[object]required
A list of messages comprising the conversation so far.
rolestringrequired
The role of the message author.
systemuserassistant
contentstringrequired
The content of the message.
max_tokensinteger
The maximum number of tokens to generate in the completion. The maximum value is the model's context length minus the prompt length.
Min: 1
temperaturenumber
Controls the variety of the model's responses. Lower values make output more predictable and deterministic, higher values more diverse and random.
Default: 1Min: 0Max: 2
streamboolean
If set to true, partial message deltas will be sent as server-sent events.
Default: false
リクエストボディの例
json
{"model":"bytedance/doubao-seed-2.0-lite-260428","messages":[{"role":"user","content":"what is difference between http and https"}],"max_tokens":65536,"temperature":0.7,"stream":false}
出力 Schema
API は ChatCompletion 互換のレスポンスを返します。
idstringrequired
Unique identifier for the completion.
objectstringrequired
Object type, always "chat.completion".
Default: "chat.completion"
createdintegerrequired
Unix timestamp of when the completion was created.
modelstringrequired
The model used for the completion.
choicesarray[object]required
List of completion choices.
indexintegerrequired
Index of the choice.
messageobjectrequired
The generated message.
finish_reasonstringrequired
The reason generation stopped.
stoplengthcontent_filter
usageobjectrequired
Token usage statistics.
prompt_tokensintegerrequired
Number of tokens in the prompt.
completion_tokensintegerrequired
Number of tokens in the completion.
total_tokensintegerrequired
Total tokens used.
レスポンス例
json
{"id":"chatcmpl-abc123","object":"chat.completion","created":1700000000,"model":"model-name","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! How can I assist you today?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":10,"completion_tokens":20,"total_tokens":30}}
Atlas Cloud Skills
Atlas Cloud Skills は 400 以上の AI モデルを AI コーディングアシスタントに直接統合します。ワンコマンドでインストールし、自然言語で画像・動画生成や LLM との対話が可能です。