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

# 快速开始

> 5 分钟快速上手 清波 API

## 前置要求

* 一个 清波 API 账户（[注册](https://qingbo.dev/login)）
* API 密钥
* 基础的编程知识

## 获取 API 密钥

<Steps>
  <Step title="登录控制台">
    访问 [Dashboard](https://qingbo.dev/dashboard/keys) 并登录
  </Step>

  <Step title="创建密钥">
    在密钥管理页面点击"创建新密钥"
  </Step>

  <Step title="保存密钥">
    复制并安全保存你的 API 密钥，密钥只显示一次
  </Step>
</Steps>

<Warning>
  请勿在前端代码或公开仓库中暴露 API Key。
</Warning>

## 发送第一个请求

清波 API 完全兼容 OpenAI SDK，只需替换 `base_url` 即可使用。

<CodeGroup>
  ```python Python theme={"system"}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://www.qingbo.dev/v1",
      api_key="YOUR_API_KEY"
  )

  response = client.chat.completions.create(
      model="gpt-4o",
      messages=[
          {"role": "user", "content": "你好，介绍一下你自己"}
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```javascript JavaScript theme={"system"}
  import OpenAI from 'openai';

  const client = new OpenAI({
    baseURL: 'https://www.qingbo.dev/v1',
    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);
  ```

  ```bash cURL theme={"system"}
  curl https://www.qingbo.dev/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -d '{
      "model": "gpt-4o",
      "messages": [
        {"role": "user", "content": "你好，介绍一下你自己"}
      ]
    }'
  ```
</CodeGroup>

## 理解响应

```json theme={"system"}
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "你好！我是一个 AI 助手..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
```

## 下一步

<CardGroup cols={2}>
  <Card title="认证与密钥" href="/cn/docs/authentication">
    了解认证方式和密钥管理
  </Card>

  <Card title="同步与异步" href="/cn/docs/sync-async">
    了解不同端点的调用方式
  </Card>

  <Card title="文本生成 API" href="/cn/api-reference/text/general-chat">
    完整的聊天 API 参数和选项
  </Card>

  <Card title="任务系统" href="/cn/docs/task-system">
    图像和视频的异步生成流程
  </Card>
</CardGroup>
