علم کے مرکز کے حصے ▾

نیویگیشن

▸ یہاں سے شروع کریں کردار کے لحاظ سے

زمرہ جات

ٹولز 52
لغت 12

ٹولز

API فوری آغاز — curl, Python, TypeScript

JoinGonka Gateway Gonka کے غیر مرکزی نیٹ ورک کے لیے ایک OpenAI + Anthropic مطابقت پذیر API فراہم کرتا ہے۔ OpenAI API (/v1/chat/completions) کے لیے لکھا گیا کوئی بھی کوڈ Gonka کے ساتھ کام کرتا ہے — بس base_url اور api_key کو تبدیل کریں۔ اور Anthropic API کے ٹولز (Claude Code) بغیر کسی پراکسی کے براہ راست /v1/messages کے ذریعے منسلک ہوتے ہیں۔

اس مضمون میں تین مقبول ترین ٹولز کے لیے تیار کوڈ کی مثالیں دی گئی ہیں: curl (کمانڈ لائن)، Python، اور TypeScript/Node.js (OpenAI-فارمیٹ)۔ Anthropic-فارمیٹ کے لیے، Claude Code ہدایات ملاحظہ کریں۔

آپ کو کیا چاہیے: ایک JoinGonka API-کلید (jg-xxx فارمیٹ)۔ gate.joingonka.ai/register پر مفت حاصل کریں، 3M ٹوکن بونس کے ساتھ۔

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)
toolsarraytool calling کے لیے فنکشن ڈیفینیشنز
tool_choicestring/objectفنکشن کال کرنے کی حکمت عملی

نیٹ ورک ماڈلز کے پیرامیٹرز: کنٹیکسٹ ونڈو — MiniMax M2.7 میں 200K ٹوکنز (DeepSeek V4 Flash میں 380K، GLM-5.3 Flash میں 390K)، زیادہ سے زیادہ جواب — 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 — $0.0069/1M ٹوکن پر OpenAI + Anthropic مطابقت پذیر API۔ curl، Python، TypeScript — صرف 3 لائن کوڈ۔ اسٹریمنگ، ٹول کالنگ اور OpenAI + Anthropic API کے تمام پیرامیٹرز۔ Claude Code براہ راست /v1/messages کے ذریعے کام کرتا ہے۔ شروع میں 3M مفت ٹوکن حاصل کریں۔

مزید جاننا چاہتے ہیں؟

دیگر حصوں کو دریافت کریں یا ابھی GNK کمانا شروع کریں۔

مفت ٹوکن حاصل کریں →