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

# 快速开始：5 分钟完成首次调用

> FocusAPI 快速开始：获取 API Key，配置 https://www.focusapi.cn/v1，用 curl 或 Python OpenAI SDK 完成首次文本对话调用。

本页只做一件事：让你快速跑通一次文本对话请求。后续图像、视频、语音等能力请从 [模型选择指南](/models/selection) 进入。

## 前提

* 已有 FocusAPI 公有云账号
* 已在控制台创建 **API Key**（`sk-` 开头）

## 1. Base URL

FocusAPI 兼容 OpenAI API v1 路径，默认 Base URL 为：

```text theme={null}
https://www.focusapi.cn/v1
```

若控制台或公告提供了区域/专线地址，以控制台显示为准。

## 2. curl 最小请求

将 `sk-your-api-key` 替换为你的真实 Key：

```bash theme={null}
curl https://www.focusapi.cn/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "user", "content": "用一句话介绍 FocusAPI"}
    ]
  }'
```

### 成功时

你会收到 JSON，其中包含 `choices[0].message.content` 等字段，HTTP 状态码为 **200**。

### 常见失败速查

| 现象                | 可能原因        | 处理                       |
| ----------------- | ----------- | ------------------------ |
| `401`             | Key 无效或未传   | 见 [401 未授权](/errors/401) |
| `429`             | 触发限流        | 见 [429 限流](/errors/429)  |
| `model not found` | 模型名错误或账号无权限 | 在控制台「模型广场」核对可用 `model`   |
| 长时间无响应后 `524`     | 上游超时        | 见 [524 超时](/errors/524)  |

## 3. Python SDK

安装 SDK 后，只需修改 `base_url` 与 `api_key`：

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://www.focusapi.cn/v1",
    api_key="sk-your-api-key",
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "user", "content": "Hello from FocusAPI"},
    ],
)
print(response.choices[0].message.content)
```

更多 Python SDK 写法见 [文本对话模型](/models/chat#python-sdk-调用)。

## 4. 换模型

请求体里的 `model` 必须使用控制台 **模型广场** 中的完整模型 ID。常见能力入口：

<CardGroup cols={2}>
  <Card title="文本对话" href="/models/chat">
    GPT、Claude、Gemini、DeepSeek 等模型的统一调用方式。
  </Card>

  <Card title="推理模型" href="/models/reasoning">
    DeepSeek Reasoner、GPT 推理模型等。
  </Card>

  <Card title="图片分析" href="/models/image-analysis">
    图片问答、截图理解、票据和图表分析。
  </Card>

  <Card title="图像生成" href="/models/image-generation">
    文生图、多轮图像创作和异步任务说明。
  </Card>

  <Card title="图像编辑" href="/models/image-editing">
    上传原图并用文本指令改图。
  </Card>

  <Card title="语音模型" href="/models/audio">
    STT、TTS、音频文件上传。
  </Card>
</CardGroup>

## 5. 流式输出（可选）

文本对话中设置 `"stream": true` 即可启用 SSE 流式返回。完整示例见 [文本对话](/models/chat#流式输出)。

## 下一步

<CardGroup cols={2}>
  <Card title="模型选择指南" href="/models/selection">
    按任务选择合适模型
  </Card>

  <Card title="错误排查" href="/errors/overview">
    按现象定位调用失败原因
  </Card>

  <Card title="计费说明" href="/billing/pricing">
    额度、倍率、用量日志
  </Card>
</CardGroup>
