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

# 基本对话

### 模型参数

* 模型ID：参考[模型选择](https://docs.geekai.co/cn/docs/chat/model)拷贝模型ID设置到 `model` 字段
* 模型参数：参考[对话 API 手册](https://docs.geekai.co/cn/api/chat/completions)
* 调用入口：`https://geekai.co/api/v1/chat/completions`（国外域名调整为 `geekai.dev`）
* API KEY：[获取 API KEY](https://docs.geekai.co/cn/docs/quick_start)

### 调用示例

以下是最简单最基础的入门对话请求示例：

<CodeGroup>
  ```bash curl theme={null}
  curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
  --header 'Authorization: Bearer $GEEKAI_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "model": "gpt-5-mini",
      "messages": [
          {
              "role": "user",
              "content": "你好"
          }
      ]
  }'
  ```

  ```bash python theme={null}
  # 先安装 OpenAI SDK: `pip3 install openai`

  from openai import OpenAI

  client = OpenAI(api_key="$GEEKAI_API_KEY", base_url="https://geekai.co/api/v1")

  response = client.chat.completions.create(
      model="gpt-5-mini",
      messages=[
          {"role": "user", "content": "你好"},
      ],
      stream=False
  )

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

  ```bash javascript theme={null}
  // 先安装 OpenAI SDK: `npm install openai`

  import OpenAI from "openai";

  const openai = new OpenAI({
      baseURL: 'https://geekai.co/api/v1',
      apiKey: '$GEEKAI_API_KEY'
  });

  async function main() {
      const completion = await openai.chat.completions.create({
          messages: [{ role: "user", content: "你好" }],
          model: "gpt-5-mini",
      });

      console.log(completion.choices[0].message.content);
  }

  main();
  ```

  ```bash go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	requestBody := map[string]interface{}{
  		"model": "gpt-5-mini",
  		"messages": []interface{}{
              map[string]interface{}{
                  "role": "user", 
                  "content": "你好",
              },
          }
  	}
  	
  	jsonData, err := json.Marshal(requestBody)
  	if err != nil {
  		panic(err)
  	}

  	client := &http.Client{}
  	req, err := http.NewRequest("POST", "https://geekai.co/api/v1/chat/completions", bytes.NewBuffer(jsonData))
  	if err != nil {
  		panic(err)
  	}

  	req.Header.Set("Authorization", "Bearer $GEEKAI_API_KEY")
  	req.Header.Set("Content-Type", "application/json")

  	resp, err := client.Do(req)
  	if err != nil {
  		panic(err)
  	}
  	defer resp.Body.Close()

  	body, err := io.ReadAll(resp.Body)
  	if err != nil {
  		panic(err)
  	}

  	fmt.Println(string(body))
  }
  ```
</CodeGroup>

以上基本示例适用于所有对话模型。
