ส่วนของฐานความรู้ ▾

การนำทาง

▸ เริ่มต้นที่นี่ ตามบทบาท

หมวดหมู่

เครื่องมือ 52
อภิธานศัพท์ 12

เครื่องมือ

API เริ่มต้นอย่างรวดเร็ว — curl, Python, TypeScript

JoinGonka Gateway มอบ OpenAI + Anthropic compatible API สำหรับ เครือข่ายแบบกระจายศูนย์ Gonka โค้ดใดๆ ที่เขียนสำหรับ OpenAI API (/v1/chat/completions) จะสามารถใช้งานกับ Gonka ได้ทันที เพียงแค่เปลี่ยน base_url และ api_key เท่านั้น ส่วนเครื่องมือบน Anthropic API (Claude Code) สามารถเชื่อมต่อผ่าน /v1/messages ได้โดยตรงโดยไม่ต้องใช้ proxy

ในบทความนี้เรามีตัวอย่างโค้ดสำหรับเครื่องมือที่ได้รับความนิยมสูงสุด 3 ตัว: curl (command line), Python และ TypeScript/Node.js (รูปแบบ OpenAI) สำหรับรูปแบบ Anthropic โปรดดู คู่มือ Claude Code

สิ่งที่คุณต้องมี: API-key ของ JoinGonka (รูปแบบ jg-xxx) รับฟรีได้ที่ gate.joingonka.ai/register พร้อมรับโบนัส 3M token

curl — คำขอจากเทอร์มินัล

วิธีที่เร็วที่สุดในการทดสอบ API คือ curl:

คำขอปกติ:

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

Streaming (ตอบกลับแบบทีละส่วน):

curl https://gate.joingonka.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer jg-your-key" \
  -d '{
    "model": "MiniMaxAI/MiniMax-M2.7",
    "messages": [
      {"role": "user", "content": "Write hello world in Python"}
    ],
    "stream": true
  }'

คำตอบจะมาในรูปแบบ JSON (ปกติ) หรือ Server-Sent Events (streaming) — เข้ากันได้เต็มรูปแบบกับ OpenAI API

Python — openai SDK

OpenAI Python SDK อย่างเป็นทางการใช้งานกับ JoinGonka Gateway ได้ทันทีโดยไม่ต้องแก้ไข:

pip install openai

คำขอปกติ:

from openai import OpenAI

client = OpenAI(
    base_url="https://gate.joingonka.ai/v1",
    api_key="jg-your-key",
)

response = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",
    messages=[
        {"role": "user", "content": "Explain blockchain in simple terms"}
    ],
)

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

Streaming:

stream = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",
    messages=[{"role": "user", "content": "Write a sorting function in Python"}],
    stream=True,
)

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

Tool calling:

import json

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the weather in a city",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "City name"}
            },
            "required": ["city"]
        }
    }
}]

response = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",
    messages=[{"role": "user", "content": "What is the weather in Moscow?"}],
    tools=tools,
)

tool_call = response.choices[0].message.tool_calls[0]
print(f"Function: {tool_call.function.name}")
print(f"Arguments: {tool_call.function.arguments}")

โมเดลในเครือข่ายรองรับ tool calling แบบเนทีฟ — ฟังก์ชันถูกเรียกอย่างถูกต้อง โดยไม่ต้องแยกวิเคราะห์ข้อความตอบกลับ

TypeScript/Node.js — openai SDK

ติดตั้ง:

npm install openai

คำขอปกติ:

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://gate.joingonka.ai/v1',
  apiKey: 'jg-your-key',
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'MiniMaxAI/MiniMax-M2.7',
    messages: [
      { role: 'user', content: 'Write an Express.js server' },
    ],
  });

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

main();

Streaming:

const stream = await client.chat.completions.create({
  model: 'MiniMaxAI/MiniMax-M2.7',
  messages: [{ role: 'user', content: 'Explain async/await' }],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content || '';
  process.stdout.write(content);
}

Tool calling:

const response = await client.chat.completions.create({
  model: 'MiniMaxAI/MiniMax-M2.7',
  messages: [{ role: 'user', content: 'Convert 100 USD to EUR' }],
  tools: [{
    type: 'function',
    function: {
      name: 'convert_currency',
      description: 'Currency conversion',
      parameters: {
        type: 'object',
        properties: {
          amount: { type: 'number' },
          from: { type: 'string' },
          to: { type: 'string' },
        },
        required: ['amount', 'from', 'to'],
      },
    },
  }],
});

const toolCall = response.choices[0].message.tool_calls?.[0];
console.log(`Function: ${toolCall?.function.name}`);
console.log(`Arguments: ${toolCall?.function.arguments}`);

ตัวอย่างทั้งหมดใช้ OpenAI SDK อย่างเป็นทางการ — ไม่ต้องติดตั้งไลบรารีเพิ่มเติม เพียงเปลี่ยน base_url และ api_key เท่านั้น

พารามิเตอร์ API ที่รองรับ

JoinGonka Gateway รองรับพารามิเตอร์มาตรฐานทั้งหมดของ OpenAI Chat Completions API:

พารามิเตอร์ประเภทคำอธิบาย
modelstringโมเดล: MiniMaxAI/MiniMax-M2.7
messagesarrayประวัติข้อความ (system, user, assistant)
streambooleanการสร้างแบบสตรีม (SSE) ค่าเริ่มต้น: false
temperaturenumberความสร้างสรรค์ของคำตอบ (0.0 — 2.0)
max_tokensintegerความยาวสูงสุดของคำตอบ (สูงสุด: 8192, สำหรับ DeepSeek V4 Flash — 32768; ค่าเริ่มต้นหากไม่ระบุ max_tokens — 1500)
toolsarrayนิยามฟังก์ชันสำหรับ tool calling
tool_choicestring/objectกลยุทธ์การเรียกฟังก์ชัน

พารามิเตอร์ของโมเดลในเครือข่าย: หน้าต่างบริบท — 200K โทเคนสำหรับ MiniMax M2.7 (380K สำหรับ DeepSeek V4 Flash, 390K สำหรับ GLM-5.3 Flash), คำตอบสูงสุด — สูงสุด 8192 โทเคน (สำหรับ DeepSeek V4 Flash — สูงสุด 32768) ดูรายการโมเดลได้ที่ GET /v1/models

สองเอนด์พอยต์:

  • รูปแบบ OpenAI: POST https://gate.joingonka.ai/v1/chat/completions
  • รูปแบบ Anthropic: POST https://gate.joingonka.ai/v1/messages

การยืนยันตัวตน: Authorization: Bearer jg-your-key (OpenAI) หรือ x-api-key: jg-your-key (Anthropic)

รูปแบบคำตอบเข้ากันได้เต็มรูปแบบกับ OpenAI และ Anthropic — SDK ไลบรารี หรือเฟรมเวิร์กใดก็ตามที่รองรับ OpenAI หรือ Anthropic API สามารถใช้งานกับ JoinGonka Gateway ได้โดยไม่ต้องแก้ไข Claude Code เชื่อมต่อผ่านรูปแบบ Anthropic โดยตรง

JoinGonka Gateway — OpenAI + Anthropic compatible API ในราคา $0.0069/1M token รองรับ curl, Python, TypeScript ด้วยโค้ดเพียง 3 บรรทัด มาพร้อม Streaming, tool calling และพารามิเตอร์ทั้งหมดของ OpenAI + Anthropic API Claude Code ใช้งานได้โดยตรงผ่าน /v1/messages รับ 3M token ฟรีตั้งแต่เริ่มต้น

ต้องการเรียนรู้เพิ่มเติมหรือไม่?

สำรวจส่วนอื่นๆ หรือเริ่มรับ GNK ทันที

รับ token ฟรี →