nav.announce

快速开始

最后更新 2026-10-05

用 OpenAI SDK 通过 Aston AI Gateway 调用模型,并让模型读取实时感知数据,大约 5 分钟。

接口为设计稿,以正式文档为准;AI Gateway Beta 计划于 2027 Q1 开放。

1

登录官网,在账户菜单打开「API 密钥」,创建一个密钥。

2

安装 OpenAI SDK:pip install openai 或 npm install openai。

3

把 base_url 改为 https://api.aston.ai/v1,发送第一个请求。

4

在 aston 扩展字段里列出允许的 Sense Tools,并设置本次 DC 上限。

Python

from openai import OpenAI

client = OpenAI(base_url='https://api.aston.ai/v1', api_key='ASTON_API_KEY')

resp = client.chat.completions.create(
    model='deepseek/deepseek-chat',
    messages=[{'role': 'user', 'content': 'Is now a good time to run near Marina Bay, Singapore?'}],
    extra_body={'aston': {
        'sense_tools': ['air_quality', 'noise', 'micro_weather'],
        'max_dc': 200,  # tool budget for this request: 200 DC = $0.02
    }},
)
print(resp.choices[0].message.content)

Node.js

import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://api.aston.ai/v1', apiKey: process.env.ASTON_API_KEY });

const resp = await client.chat.completions.create({
  model: 'deepseek/deepseek-chat',
  messages: [{ role: 'user', content: 'Is now a good time to run near Marina Bay, Singapore?' }],
  aston: { sense_tools: ['air_quality', 'noise'], max_dc: 200 }, // Aston extension field
});
console.log(resp.choices[0].message.content);

cURL

curl https://api.aston.ai/v1/chat/completions \
  -H "Authorization: Bearer $ASTON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek/deepseek-chat", "messages": [{"role": "user", "content": "Is now a good time to run near Marina Bay?"}], "aston": {"sense_tools": ["air_quality"], "max_dc": 200}}'

这页有帮助吗?