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

สำหรับนักลงทุน

เครื่องมือ

เครื่องมือ

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

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

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

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

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

วิธีที่เร็วที่สุดในการตรวจสอบการทำงานของ API — curl:

คำขอปกติ:

curl https://gate.joingonka.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer jg-your-key" \
  -d '{
    "model": "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    "messages": [
      {"role": "user", "content": "Gonka คืออะไร?"}
    ]
  }'

Streaming (ตอบกลับเป็นส่วนๆ):

curl https://gate.joingonka.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer jg-your-key" \
  -d '{
    "model": "Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    "messages": [
      {"role": "user", "content": "เขียน hello world ด้วย 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="Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    messages=[
        {"role": "user", "content": "อธิบาย blockchain ง่ายๆ"}
    ],
)

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

Streaming:

stream = client.chat.completions.create(
    model="Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    messages=[{"role": "user", "content": "เขียนอัลกอริทึมการจัดเรียงด้วย 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": "รับสภาพอากาศในเมือง",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "ชื่อเมือง"}
            },
            "required": ["city"]
        }
    }
}]

response = client.chat.completions.create(
    model="Qwen/Qwen3-235B-A22B-Instruct-2507-FP8",
    messages=[{"role": "user", "content": "สภาพอากาศในมอสโกเป็นอย่างไร?"}],
    tools=tools,
)

tool_call = response.choices[0].message.tool_calls[0]
print(f"ฟังก์ชัน: {tool_call.function.name}")
print(f"อาร์กิวเมนต์: {tool_call.function.arguments}")

Qwen3-235B รองรับ native 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: 'Qwen/Qwen3-235B-A22B-Instruct-2507-FP8',
    messages: [
      { role: 'user', content: 'เขียน Express.js server' },
    ],
  });

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

main();

Streaming:

const stream = await client.chat.completions.create({
  model: 'Qwen/Qwen3-235B-A22B-Instruct-2507-FP8',
  messages: [{ role: 'user', content: 'อธิบาย 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: 'Qwen/Qwen3-235B-A22B-Instruct-2507-FP8',
  messages: [{ role: 'user', content: 'แปลง 100 USD เป็น EUR' }],
  tools: [{
    type: 'function',
    function: {
      name: 'convert_currency',
      description: 'แปลงสกุลเงิน',
      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(`ฟังก์ชัน: ${toolCall?.function.name}`);
console.log(`อาร์กิวเมนต์: ${toolCall?.function.arguments}`);

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

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

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

พารามิเตอร์ประเภทคำอธิบาย
modelstringโมเดล: Qwen/Qwen3-235B-A22B-Instruct-2507-FP8
messagesarrayประวัติข้อความ (system, user, assistant)
streambooleanการสร้างแบบสตรีมมิ่ง (SSE). ค่าเริ่มต้น: false
temperaturenumberความสร้างสรรค์ของการตอบกลับ (0.0 — 2.0)
max_tokensintegerความยาวสูงสุดของการตอบกลับ (สูงสุด: 2048, ค่าเริ่มต้น: 1024)
toolsarrayคำจำกัดความฟังก์ชันสำหรับการเรียกใช้เครื่องมือ
tool_choicestring/objectกลยุทธ์การเรียกใช้ฟังก์ชัน

พารามิเตอร์โมเดล Qwen3-235B: หน้าต่างบริบท — 128K โทเค็น, การตอบกลับสูงสุด — 2048 โทเค็น. รายละเอียดทั้งหมด: HuggingFace. รายชื่อโมเดลสามารถดูได้ที่ GET /v1/models.

สองปลายทาง (endpoints):

  • รูปแบบ 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 — API ที่เข้ากันได้กับ OpenAI + Anthropic ในราคา $0.001/1M โทเค็น. curl, Python, TypeScript — โค้ด 3 บรรทัด. Streaming, tool calling, พารามิเตอร์ทั้งหมดของ OpenAI + Anthropic API. Claude Code ทำงานโดยตรงผ่าน /v1/messages. โทเค็นฟรี 10M เมื่อเริ่มต้น.

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

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

รับ 10M โทเค็นฟรี →