> Dành cho AI agent: hướng dẫn từng bước để thiết lập — [`/docs/agents.md`](https://gate.joingonka.ai/docs/agents.md), chỉ mục tài liệu — [`/llms.txt`](https://gate.joingonka.ai/llms.txt).

# Kết nối các mô hình Gonka với công cụ của bạn

API tương thích OpenAI và Anthropic. Chọn công cụ của bạn — nhận lệnh cài đặt, prompt cho agent và bước kiểm tra.

## Thông tin nhanh

- Base URL cho client OpenAI API: `https://gate.joingonka.ai/v1`
- Base URL cho client Anthropic API, không có `/v1`: `https://gate.joingonka.ai`
- Key được truyền trong header `Authorization: Bearer jg-…` hoặc `x-api-key: jg-…`
- Danh sách mô hình khả dụng: `GET https://gate.joingonka.ai/v1/models`
- Mô hình đề xuất: `MiniMaxAI/MiniMax-M2.7`

## Kết nối công cụ

Chọn công cụ của bạn — bên dưới là ba bước dành riêng cho nó. Trình cài đặt thiết lập bằng một lệnh cho các công cụ trong bảng bên dưới (25 công cụ), các công cụ còn lại kết nối theo hướng dẫn.

### Key

Đăng ký tại [gate.joingonka.ai](https://gate.joingonka.ai/register) và tạo key trong trang cá nhân. Ngay sau khi đăng ký, tài khoản sẽ được tặng 3M token miễn phí.

### Kết nối

Trình cài đặt tự cấu hình công cụ: hỏi key với nhập ẩn, ghi file config và kiểm tra kết nối. Giá trị cho `--tool` có trong bảng công cụ bên dưới.

```bash
npx -y @joingonka/setup --tool <id> --model MiniMaxAI/MiniMax-M2.7
```

Hoặc giao cho AI agent thiết lập — gửi cho nó prompt sau:

```text
Kết nối công cụ của bạn với JoinGonka Gateway — API tương thích OpenAI và Anthropic của mạng Gonka — theo hướng dẫn tại https://gate.joingonka.ai/docs/agents.md. Tôi sẽ tự đưa key: đừng lưu key vào file trong repo và đừng thay đổi biến môi trường toàn cục. Cuối cùng, kiểm tra kết nối bằng một request ngắn và báo kết quả.
```

Hướng dẫn từng bước cho mỗi công cụ — theo liên kết trong bảng bên dưới.

### Kiểm tra

Số dư tài khoản — request này không tốn token:

```bash
curl -s https://gate.joingonka.ai/api/balance \
  -H "Authorization: Bearer $JOINGONKA_API_KEY"
```

Request ngắn tới mô hình — phản hồi với mã 200 nghĩa là mọi thứ đã được cấu hình:

```bash
curl -s https://gate.joingonka.ai/v1/chat/completions \
  -H "Authorization: Bearer $JOINGONKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "MiniMaxAI/MiniMax-M2.7", "messages": [{"role": "user", "content": "Say OK"}], "max_tokens": 32}'
```

### Tất cả công cụ

| Công cụ | Loại | Trình cài đặt |
| --- | --- | --- |
| [Cursor](https://joingonka.ai/vi/knowledge/cursor/) | IDE | `--tool cursor` |
| [Claude Code](https://joingonka.ai/vi/knowledge/claude-code/) | CLI agent | `--tool claude-code` |
| [OpenClaw](https://joingonka.ai/vi/knowledge/openclaw/) | CLI agent | `--tool openclaw` |
| [OpenCode](https://joingonka.ai/vi/knowledge/opencode/) | CLI agent | `--tool opencode` |
| [Continue](https://joingonka.ai/vi/knowledge/continue-dev/) | IDE | `--tool continue` |
| [Cline](https://joingonka.ai/vi/knowledge/cline/) | IDE | `--tool cline` |
| [Aider](https://joingonka.ai/vi/knowledge/aider/) | CLI agent | `--tool aider` |
| [LangChain](https://joingonka.ai/vi/knowledge/langchain/) | Framework | — |
| [n8n](https://joingonka.ai/vi/knowledge/n8n/) | Framework | — |
| [Open WebUI](https://joingonka.ai/vi/knowledge/open-webui/) | Chat | — |
| [LibreChat](https://joingonka.ai/vi/knowledge/librechat/) | Chat | — |
| [Hermes](https://joingonka.ai/vi/knowledge/hermes/) | CLI agent | `--tool hermes` |
| [Kilo Code](https://joingonka.ai/vi/knowledge/kilo-code/) | IDE | `--tool kilo` |
| [Roo Code](https://joingonka.ai/vi/knowledge/roo-code/) | IDE | `--tool roo` |
| [LlamaIndex](https://joingonka.ai/vi/knowledge/llamaindex/) | Framework | — |
| [PydanticAI](https://joingonka.ai/vi/knowledge/pydantic-ai/) | Framework | — |
| [Vercel AI SDK](https://joingonka.ai/vi/knowledge/vercel-ai-sdk/) | Framework | — |
| [TanStack AI](https://joingonka.ai/vi/knowledge/tanstack-ai/) | Framework | — |
| [ZCode](https://joingonka.ai/vi/knowledge/zcode/) | CLI agent | `--tool zcode` |
| [JetBrains](https://joingonka.ai/vi/knowledge/jetbrains/) | IDE | `--tool jetbrains` |
| [Copilot BYOK](https://joingonka.ai/vi/knowledge/copilot-byok/) | IDE | `--tool copilot-byok` |
| [Zed](https://joingonka.ai/vi/knowledge/zed/) | IDE | `--tool zed` |
| [Pi](https://joingonka.ai/vi/knowledge/pi/) | CLI agent | `--tool pi` |
| [Codex CLI](https://joingonka.ai/vi/knowledge/codex/) | CLI agent | `--tool codex` |
| [DeepSeek Harness](https://joingonka.ai/vi/knowledge/deepseek-harness/) | CLI agent | — |
| [MiniMax Code](https://joingonka.ai/vi/knowledge/minimax-code/) | CLI agent | `--tool minimax-code` |
| [Warp](https://joingonka.ai/vi/knowledge/warp/) | CLI agent | — |
| [Trae](https://joingonka.ai/vi/knowledge/trae/) | IDE | — |
| [Cherry Studio](https://joingonka.ai/vi/knowledge/cherry-studio/) | Chat | — |
| [omp (Oh My Pi)](https://joingonka.ai/vi/knowledge/omp/) | CLI agent | `--tool omp` |
| [OpenHands](https://joingonka.ai/vi/knowledge/openhands/) | CLI agent | — |
| [Qwen Code](https://joingonka.ai/vi/knowledge/qwen-code/) | CLI agent | `--tool qwen-code` |
| [Goose](https://joingonka.ai/vi/knowledge/goose/) | CLI agent | `--tool goose` |
| [Crush](https://joingonka.ai/vi/knowledge/crush/) | CLI agent | `--tool crush` |
| [Zoo Code](https://joingonka.ai/vi/knowledge/zoo-code/) | IDE | `--tool zoo` |
| [Kimi Code](https://joingonka.ai/vi/knowledge/kimi-code/) | CLI agent | `--tool kimi-code` |
| [Factory Droid](https://joingonka.ai/vi/knowledge/factory-droid/) | CLI agent | `--tool droid` |
| [MiMo Code](https://joingonka.ai/vi/knowledge/mimo-code/) | CLI agent | `--tool mimo-code` |

## Ví dụ code

Cùng một request qua OpenAI SDK, cURL và Anthropic SDK. Key được lấy từ biến môi trường `JOINGONKA_API_KEY`.

### Python

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://gate.joingonka.ai/v1",
    api_key=os.environ["JOINGONKA_API_KEY"],
)

response = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",
    messages=[{"role": "user", "content": "What is Gonka?"}],
)
print(response.choices[0].message.content)
```

### TypeScript

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://gate.joingonka.ai/v1",
  apiKey: process.env.JOINGONKA_API_KEY,
});

const response = await client.chat.completions.create({
  model: "MiniMaxAI/MiniMax-M2.7",
  messages: [{ role: "user", content: "What is Gonka?" }],
});
console.log(response.choices[0].message.content);
```

### cURL

```bash
curl https://gate.joingonka.ai/v1/chat/completions \
  -H "Authorization: Bearer $JOINGONKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMaxAI/MiniMax-M2.7",
    "messages": [{"role": "user", "content": "What is Gonka?"}]
  }'
```

### Anthropic SDK

```python
import os
import anthropic

client = anthropic.Anthropic(
    base_url="https://gate.joingonka.ai",
    api_key=os.environ["JOINGONKA_API_KEY"],
)

message = client.messages.create(
    model="MiniMaxAI/MiniMax-M2.7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "What is Gonka?"}],
)
print(message.content[0].text)
```

## Các mục tài liệu

- [API](https://gate.joingonka.ai/vi/docs/api) — Tham chiếu API tương thích OpenAI và Anthropic cho các mô hình trên mạng Gonka: khóa, tham số, streaming, công cụ, plugin. Token miễn phí khi đăng ký.
- [Mô hình](https://gate.joingonka.ai/vi/docs/models) — Các mô hình mạng Gonka trong một API duy nhất: id cho trường model, ngữ cảnh, giới hạn phản hồi, giá và trạng thái. Cùng những mô hình mở với giá rẻ hơn nhiều lần.
- [Lỗi và giới hạn](https://gate.joingonka.ai/vi/docs/errors) — Mã lỗi cổng, giới hạn yêu cầu và thời gian chờ: ý nghĩa của từng phản hồi và khi nào nên thử lại.
- [Bảng giá và tài khoản](https://gate.joingonka.ai/vi/docs/billing) — Các mô hình mạng Gonka theo giá mỗi token: token miễn phí khi bắt đầu, nạp bằng GNK, USDT hoặc thẻ, mọi khoản phí đều công khai và API tài khoản để theo dõi chi phí.
- [Dành cho agent](https://gate.joingonka.ai/vi/docs/agents) — Gửi liên kết cho AI agent — nó sẽ tự kết nối Claude Code, Cursor hoặc Codex với các mô hình trên mạng Gonka: prompt sẵn sàng, hướng dẫn và skill.
