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

# Bắt đầu nhanh

> Bắt đầu với TokenLab API trong 2 phút

## Bước 1: Bắt đầu với credits dùng thử

<Steps>
  <Step title="Tạo tài khoản">
    Đăng ký tại [tokenlab.sh](https://tokenlab.sh) bằng email, Gmail hoặc tài khoản GitHub của bạn.
  </Step>

  <Step title="Dùng credits dùng thử được tặng">
    Tài khoản mới có credits dùng thử cho các yêu cầu kiểm thử nhỏ đầu tiên. Bạn không cần nạp tiền trước Quickstart.
  </Step>

  <Step title="Tạo hoặc sao chép khóa API">
    Vào **Dashboard → API Keys** và tạo khóa mới, hoặc sao chép khóa hiện có. Hãy lưu khóa an toàn vì khóa đầy đủ chỉ hiển thị một lần.
  </Step>
</Steps>

<Warning>
  Giữ khóa API của bạn an toàn. Không bao giờ để lộ nó trong mã phía client hoặc kho lưu trữ công cộng.
</Warning>

## Bước 2: Cài đặt client

<CodeGroup>
  ```bash Python theme={null}
  pip install openai
  ```

  ```bash JavaScript theme={null}
  npm install openai
  ```

  ```bash Go theme={null}
  go get github.com/openai/openai-go/v3
  ```

  ```bash PHP theme={null}
  composer require openai-php/client
  ```
</CodeGroup>

## Bước 3: Thực hiện yêu cầu đầu tiên

Đối với hầu hết các tích hợp mới, bắt đầu với **Chat Completions** qua `POST /v1/chat/completions`.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.tokenlab.sh/v1/chat/completions \
    -H "Authorization: Bearer sk-your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.4",
      "messages": [
        {"role": "user", "content": "What is the capital of France?"}
      ]
    }'
  ```

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

  client = OpenAI(
      api_key="sk-your-api-key",
      base_url="https://api.tokenlab.sh/v1"
  )

  response = client.chat.completions.create(
      model="gpt-5.4",
      messages=[{"role": "user", "content": "What is the capital of France?"}]
  )

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

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

  const client = new OpenAI({
    apiKey: 'sk-your-api-key',
    baseURL: 'https://api.tokenlab.sh/v1'
  });

  const response = await client.chat.completions.create({
    model: 'gpt-5.4',
    messages: [{ role: 'user', content: 'What is the capital of France?' }],
  });

  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

<Note>
  Chỉ sử dụng `POST /v1/responses` khi bạn thực sự cần hành vi đặc thù của Responses. Một số trường chỉ dành cho Responses phụ thuộc vào model được chọn và đường dẫn được định tuyến.
</Note>

## Nạp tiền cho môi trường production

Credits dùng thử được tặng dành cho các kiểm thử nhỏ đầu tiên. Chỉ thêm credits trong **Dashboard → Billing** khi bạn đã sẵn sàng dùng production hoặc kiểm thử với lưu lượng cao hơn.

## Thử các mô hình khác

TokenLab hỗ trợ hàng trăm mô hình. Chỉ thay đổi trường `model`:

```python theme={null}
response = client.chat.completions.create(model="gpt-5.4", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="gpt-5-mini", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="gemini-3.5-flash", messages=[{"role": "user", "content": "Hello"}])
response = client.chat.completions.create(model="deepseek-r1", messages=[{"role": "user", "content": "Hello"}])
```

## Bật Streaming

```python theme={null}
stream = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "Tell me a short story."}],
    stream=True
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="")
```

## Tiếp theo?

<CardGroup cols={2}>
  <Card title="Xác thực" icon="key" href="/authentication">
    Tìm hiểu về quản lý khóa API và bảo mật.
  </Card>

  <Card title="OpenAI SDK" icon="code" href="/integrations/openai-sdk">
    Sử dụng các tuyến tương thích OpenAI `/v1` với các SDK OpenAI hiện có.
  </Card>

  <Card title="Tham khảo API" icon="book" href="/api-reference/introduction">
    Khám phá toàn bộ tham chiếu endpoint.
  </Card>

  <Card title="Mô hình" icon="robot" href="https://tokenlab.sh/vi/models">
    Xem các mô hình hiện có và giá cả.
  </Card>
</CardGroup>
