第2章 你的第一次 API 调用
关于完整的文档索引,请参阅 llms.txt。本页面也可提供为 Markdown 格式。
你的第一次 API 调用
Arcee 平台的 API 兼容 OpenAI。 参数 值 base_url https://api.arcee.ai/api/v1/chat/completions api_key 生成 API 密钥
1. 生成 API 密钥 在 Arcee 平台仪表板中创建 API 密钥。
2. 选择模型 指定要运行的模型。Arcee 提供了一系列开源模型,完整列表见定价页面。
3. 运行代码片段 在下面的示例代码中使用你的 API 密钥和模型名称来发起首次请求。
curl -X POST "https://api.arcee.ai/api/v1/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "MODEL_NAME", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Greetings!"} ], "stream": false }'
from openai import OpenAI
client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.arcee.ai/api/v1" )
response = client.chat.completions.create( model="MODEL_NAME", messages=[ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "What is 25 + 37?"}, ], stream=False )
print(response.choices[0].message.content) print(response.choices[0].message.reasoning)
上一篇:Trinity-Large-Thinking 下一篇:Chat Completion 最后更新于 1 个月前