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

# 快速开始

> 几行代码，完成你的第一次模型调用。

export const ConsoleLink = ({path = "/console", children}) => <a href={"http://localhost:3001" + path} target="_blank" rel="noopener noreferrer">{children}</a>;

<Info>一把密钥，连接多家模型。请从控制台复制实际区域地址和模型 ID；下方域名与模型仅为占位符。</Info>

<Steps>
  <Step title="创建 API 密钥">
    在控制台为你的应用创建独立密钥，并使用环境变量保存。

    ```bash theme={null}
    export CODEFLARE_API_KEY="YOUR_CODEFLARE_KEY"
    ```

    <ConsoleLink path="/console/keys">管理 API 密钥 ↗</ConsoleLink>
  </Step>

  <Step title="选择区域与模型">
    在密钥页复制所选区域的 Base URL，在模型详情中复制兼容 Responses 协议的模型 ID。

    | 配置 | 示例占位符 |
    | - | - |
    | Base URL | `https://YOUR-REGION.example/v1` |
    | 模型 ID | `MODEL_ID` |

    <ConsoleLink path="/console/models">查看模型与协议 ↗</ConsoleLink>
  </Step>

  <Step title="发起第一次请求">
    安装对应 SDK，然后替换地址与模型。Python 使用 `python -m pip install openai`；JavaScript 使用 `npm install openai`。

    <CodeGroup>
      ```python Python theme={null}
      from openai import OpenAI
      import os

      client = OpenAI(
          api_key=os.environ["CODEFLARE_API_KEY"],
          base_url="https://YOUR-REGION.example/v1",
          max_retries=0,
      )
      response = client.responses.create(
          model="MODEL_ID", input="Hello",
          max_output_tokens=256, store=False,
      )
      print(response.output_text)
      ```

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

      const client = new OpenAI({
        apiKey: process.env.CODEFLARE_API_KEY,
        baseURL: "https://YOUR-REGION.example/v1",
        maxRetries: 0,
      });
      const response = await client.responses.create({
        model: "MODEL_ID", input: "Hello",
        max_output_tokens: 256, store: false,
      });
      console.log(response.output_text);
      ```

      ```bash cURL theme={null}
      curl "https://YOUR-REGION.example/v1/responses" \
        -H "Authorization: Bearer $CODEFLARE_API_KEY" \
        -H 'Content-Type: application/json' \
        -d '{"model":"MODEL_ID","input":"Hello","max_output_tokens":256,"store":false}'
      ```
    </CodeGroup>
  </Step>
</Steps>

<Warning>请求中断后请先检查结果，避免重复生成。示例关闭 SDK 自动重试，不会替你执行请求。</Warning>

## 接下来

<CardGroup cols={2}>
  <Card title="了解协议与鉴权" icon="code" href="/zh/api/overview">根据模型选择匹配的请求格式。</Card>
  <Card title="配置 Codex CLI" icon="terminal" href="/zh/tools/codex">使用 Responses 自定义 Provider。</Card>
  <Card title="配置 Claude Code" icon="terminal" href="/zh/tools/claude-code">使用 Anthropic Messages 网关。</Card>
  <Card title="排查调用问题" icon="circle-question" href="/zh/troubleshooting">检查密钥、余额、区域与能力。</Card>
</CardGroup>


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