艾塔达克提供多种语言的官方 SDK,帮助您快速集成 AI 能力到您的应用中。
pip install atdak
npm install atdak
# 或
pnpm add atdak
from atdak import Atdak
client = Atdak(api_key="YOUR_API_KEY")
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "你好!"}
]
)
print(response.choices[0].message.content)
import { Atdak } from 'atdak';
const client = new Atdak({ apiKey: 'YOUR_API_KEY' });
const response = await client.chat.completions.create({
model: 'gpt-4o',
messages: [
{ role: 'user', content: '你好!' }
]
});
console.log(response.choices[0].message.content);
| 特性 | Python | Node.js |
|---|---|---|
| 同步请求 | ✅ | ✅ |
| 异步请求 | ✅ | ✅ |
| 流式响应 | ✅ | ✅ |
| 自动重试 | ✅ | ✅ |
| TypeScript 类型 | - | ✅ |
| 代理支持 | ✅ | ✅ |
所有 SDK 都支持通过环境变量配置 API Key:
export ATDAK_API_KEY="your-api-key"
这样在代码中就不需要显式传入 API Key:
# Python - 自动读取环境变量
client = Atdak()
// Node.js - 自动读取环境变量
const client = new Atdak();
如果您使用的语言没有官方 SDK,可以直接调用 REST API:
curl -X POST https://api.atdak.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "你好!"}]
}'