> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# 获取 API Key 并发起第一次调用

> 创建 AIsa 账户、生成 API key，并用 curl 向模型和数据 API 发起第一次请求。

本页带你从零开始，在几分钟内完成一次可用的请求。全程只需一个 API key 和普通 HTTP。

## 1. 创建账户和 key

1. 在 [console.aisa.one](https://console.aisa.one) 使用邮箱、Google 或 GitHub 注册。新账户自带免费额度供测试。
2. 打开 [API Keys](https://console.aisa.one/api-keys)。系统已为你创建了一个 key，复制即可。Key 以 `sk-` 开头。
3. 将其存为环境变量，而非写在代码里：

```bash theme={null}
export AISA_API_KEY="sk-..."
```

你可以随时创建更多 key——每个应用或环境一个是个好习惯——并为每个 key 设置消费上限。详见[身份验证](https://aisa.one/docs/zh/guides/authentication.md)。

## 2. 调用模型

```bash theme={null}
curl https://api.aisa.one/v1/chat/completions \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [{"role": "user", "content": "Explain an AI gateway in one sentence."}]
  }'
```

响应遵循 OpenAI Chat Completions 格式：回答位于 `choices[0].message.content`，`usage` 报告被计费的 token 数。将 `model` 替换为[模型目录](https://aisa.one/docs/zh/guides/models.md)中的任意 ID——`claude-haiku-4-5-20251001`、`deepseek-v4.1-flash`、`gemini-3.8-flash`——无需改动其他任何内容。

> [!NOTE]
>
> 始终在带有 JSON body 的请求中发送 `Content-Type: application/json`；缺少该 header 会导致请求被拒绝。

## 3. 调用数据 API

数据 API 位于 `https://api.aisa.one/apis/v1`，使用同一个 API key。例如，执行一次网页搜索：

```bash theme={null}
curl https://api.aisa.one/apis/v1/tavily/search \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "latest developments in AI agents"}'
```

浏览 [API 参考](https://aisa.one/docs/zh/api-reference.md)查看完整端点列表（金融、社交、搜索、SEO 等），每个端点都附有交互式 playground。数据 API 调用会产生费用：部分端点按次收取固定费用，其余则根据请求返回的内容按量计费。详见[计费与额度](https://aisa.one/docs/zh/guides/pricing.md)了解报价和消费上限。

## 4. 查看消费情况

每次调用都会出现在 [控制台 → Usage & Logs](https://console.aisa.one/logs) 中，包含端点、模型、token 数和费用。若要通过代码读取相同的汇总数据：

```bash theme={null}
curl --get https://api.aisa.one/v1/usage \
  -H "Authorization: Bearer $AISA_API_KEY" \
  --data-urlencode "start_time=$(($(date +%s) - 86400))"
```

## 后续步骤

> [card] [OpenAI / Anthropic SDK](https://aisa.one/docs/zh/get-started/sdk-compatibility.md)
>
> 只需更改 base URL 和 key，即可使用你现有的 SDK。

> [card] [连接你的智能体](https://aisa.one/docs/zh/agent-quickstart.md)
>
> 通过 MCP 将 AIsa 作为工具接入 Claude Code、Codex 或 Cursor。

> [card] [计费与额度](https://aisa.one/docs/zh/guides/pricing.md)
>
> token 和调用如何计费、报价与消费上限。

> [card] [控制台](https://aisa.one/docs/zh/guides/dashboard/overview.md)
>
> 余额、key、playground 和逐请求日志。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.