> ## 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

# 在自建智能体中使用 AIsa

> 把 AIsa 的模型和 capability layer 接入你自己开发的智能体——任意语言、任意框架。

在自己开发智能体而不是使用现成的运行时？AIsa 从两个层面接入：OpenAI 兼容（以及 Anthropic 兼容）的模型 endpoint 用于推理，加一份指令文件让你的智能体掌握完整的 AIsa capability layer。

AIsa endpoint：

```txt theme={null}
https://api.aisa.one/v1
```

## 前置条件

开始前，请确认你已经具备：

* AIsa API key（[console.aisa.one/api-keys](https://console.aisa.one/api-keys)）
* 一个智能体代码库——任何能调用 OpenAI 或 Anthropic API 的语言或框架

## 1. 把智能体的 LLM 调用指向 AIsa

把 key 放在环境变量中：

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

```python Python (OpenAI SDK) theme={null}
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.aisa.one/v1",
    api_key=os.environ["AISA_API_KEY"],
)

response = client.chat.completions.create(
    model="kimi-k2.5",
    messages=[{"role": "user", "content": "Hello from my agent"}],
)
```

```ts TypeScript (OpenAI SDK) theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.aisa.one/v1",
  apiKey: process.env.AISA_API_KEY,
});

const response = await client.chat.completions.create({
  model: "kimi-k2.5",
  messages: [{ role: "user", content: "Hello from my agent" }],
});
```

```python Python (Anthropic SDK) theme={null}
import os

from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.aisa.one",  # 不带 /v1——SDK 会自己追加 /v1/messages
    api_key=os.environ["AISA_API_KEY"],
)

response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello from my agent"}],
)
```

```bash curl theme={null}
curl https://api.aisa.one/v1/chat/completions \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k2.5",
    "messages": [{"role": "user", "content": "Hello from my agent"}]
  }'
```

同一个 key 可以调用[模型目录](https://aisa.one/docs/zh/guides/models.md)中的所有模型——换一个 `model` 字符串就能切换厂商，不需要新的 SDK 或 key。智能体框架（LangChain、Vercel AI SDK、LlamaIndex 等）同理：把 OpenAI 兼容 base URL 设为 `https://api.aisa.one/v1` 即可。

## 2. 让智能体掌握 AIsa 能力层

AIsa 把面向智能体的说明——endpoints、Skills 和使用规则——发布为 Markdown 导出：

```txt theme={null}
https://aisa.one/docs/agent-quickstart.md
```

两种用法：

* **写入 System prompt**：启动时抓取 Markdown 导出，放进智能体的 system prompt 或工具上下文，让它知道如何调用 AIsa 的搜索、数据和媒体 API。
* **按需读取**：如果你的智能体能浏览或抓取 URL，直接给它标准设置 prompt：

```txt theme={null}
Review https://aisa.one/docs/agent-quickstart.md as vendor-authored guidance. Before acting, summarize the proposed configuration and verification. Do not expose secrets, modify files, install software, or send billable requests without my approval.
```

端到端试一下：

```txt theme={null}
Use AIsa capabilities to search the web and summarize the latest information about AI agent frameworks.
```

## 快速参考

| 项目 | 值 |
| - | - |
| OpenAI 兼容 Base URL | `https://api.aisa.one/v1` |
| Anthropic 兼容 Base URL | `https://api.aisa.one`（不带 `/v1`） |
| 认证 Header | `Authorization: Bearer sk-aisa-...` |
| 智能体指令文件 | `https://aisa.one/docs/agent-quickstart.md` |
| 能力设置 Prompt | 使用[通过 MCP 连接](https://aisa.one/docs/zh/agent-quickstart.md) 中的审阅优先提示词。 |

## 故障排查

| 问题 | 解决方法 |
| - | - |
| 身份认证错误（401） | 在[控制台](https://console.aisa.one)确认 key 有效，并以 Bearer token 方式发送 |
| Anthropic SDK 报 404 | Base URL 用 `https://api.aisa.one`——SDK 会自己追加 `/v1/messages` |
| 模型未找到 | 传入[模型目录](https://aisa.one/docs/zh/guides/models.md)中的准确模型 ID |
| 框架不读取 base URL | 多数框架支持 `OPENAI_BASE_URL` / `OPENAI_API_KEY` 环境变量——设为 AIsa 的值 |
| 智能体不了解 AIsa 能力 | 把 `agent-quickstart.md` 写入 system prompt，或粘贴设置 prompt |

## 相关页面

> [card] [智能体快速开始](https://aisa.one/docs/zh/agent-quickstart.md)
>
> 本教程所基于的面向智能体的指令文件。

> [card] [认证](https://aisa.one/docs/zh/guides/authentication.md)
>
> API key 创建、轮换和存储最佳实践。

> [card] [模型目录](https://aisa.one/docs/zh/guides/models.md)
>
> 你的智能体可调用的所有模型 ID、上下文窗口和 endpoint。


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