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

نیویگیشن

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

زمرہ جات

ٹولز 32
لغت 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-xxxgate.joingonka.ai/register پر 10M ٹوکنز کے بونس کے ساتھ مفت حاصل کریں۔

curl — ٹرمینل سے درخواست

API کو چیک کرنے کا تیز ترین طریقہ curl ہے:

عام ریکویسٹ:

curl https://gate.joingonka.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer jg-ваш-ключ" \
  -d '{
    "model": "MiniMaxAI/MiniMax-M2.7",
    "messages": [
      {"role": "user", "content": "Gonka کیا ہے؟"}
    ]
  }'

Streaming (ٹکڑوں میں جواب):

curl https://gate.joingonka.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer jg-ваш-ключ" \
  -d '{
    "model": "MiniMaxAI/MiniMax-M2.7",
    "messages": [
      {"role": "user", "content": "Python میں ہیلو ورلڈ لکھو"}
    ],
    "stream": true
  }'

جواب JSON (عام) یا Server-Sent Events (streaming) فارمیٹ میں آتا ہے — جو مکمل طور پر OpenAI API کے ساتھ مطابقت رکھتا ہے۔

Python — openai SDK

سرکاری OpenAI Python SDK بغیر کسی تبدیلی کے JoinGonka Gateway کے ساتھ کام کرتا ہے:

pip install openai

عام درخواست (Request):

from openai import OpenAI

client = OpenAI(
    base_url="https://gate.joingonka.ai/v1",
    api_key="jg-ваш-ключ",
)

response = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",
    messages=[
        {"role": "user", "content": "بلاک چین کو سادہ الفاظ میں سمجھائیں"}
    ],
)

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

Streaming:

stream = client.chat.completions.create(
    model="MiniMaxAI/MiniMax-M2.7",
    messages=[{"role": "user", "content": "پائتھون میں سارٹنگ کوڈ لکھیں"}],
    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="MiniMaxAI/MiniMax-M2.7",
    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}")

Kimi K2.6 مقامی طور پر tool calling کو سپورٹ کرتا ہے — فنکشنز صیح طریقے سے کال ہوتے ہیں، بغیر کسی ٹیکسٹ رسپانس پارسنگ کے۔

TypeScript/Node.js — openai SDK

انسٹالیشن:

npm install openai

عام درخواست (Regular request):

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://gate.joingonka.ai/v1',
  apiKey: 'jg-آپ-کی-کلید',
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'MiniMaxAI/MiniMax-M2.7',
    messages: [
      { role: 'user', content: 'ایک Express.js سرور لکھیں' },
    ],
  });

  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: '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: '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ماڈل: MiniMaxAI/MiniMax-M2.7
messagesarrayپیغام کی ہسٹری (system, user, assistant)
streambooleanاسٹریمنگ جنریشن (SSE)۔ بطور ڈیفالٹ: false
temperaturenumberتخلیقی صلاحیت (0.0 — 2.0)
max_tokensintegerجواب کی زیادہ سے زیادہ لمبائی (زیادہ سے زیادہ: 8192 نیٹ ورک کے تمام ماڈلز کے لیے؛ max_tokens کے بغیر ڈیفالٹ — 1500)
toolsarrayٹول کالنگ کے لیے فنکشن کی تعریفیں
tool_choicestring/objectفنکشن کال کرنے کی حکمت عملی

نیٹ ورک ماڈل پیرامیٹرز: کانٹیکسٹ ونڈو — 200K ٹوکنز، زیادہ سے زیادہ جواب — 8192 ٹوکنز تک (نیٹ ورک کے تمام ماڈلز کے لیے)۔ ماڈلز کی فہرست GET /v1/models کے ذریعے حاصل کی جا سکتی ہے۔

دو اینڈ پوائنٹس (Endpoint):

  • OpenAI-فارمیٹ: POST https://gate.joingonka.ai/v1/chat/completions
  • Anthropic-فارمیٹ: POST https://gate.joingonka.ai/v1/messages

توثیق (Authentication): Authorization: Bearer jg-ваш-ключ (OpenAI) یا x-api-key: jg-ваш-ключ (Anthropic)

رسپانس کا فارمیٹ OpenAI اور Anthropic کے ساتھ مکمل مشابہت رکھتا ہے — کوئی بھی SDK، لائبریری یا فریم ورک جو OpenAI یا Anthropic API کو سپورٹ کرتا ہے، وہ بغیر تبدیلی کے JoinGonka Gateway کے ساتھ کام کرتا ہے۔ Claude Code براہ راست Anthropic فارمیٹ کے ذریعے کنیکٹ ہوتا ہے۔

JoinGonka Gateway — $0.003/1M ٹوکنز پر OpenAI + Anthropic مطابقت پذیر API۔ curl، Python، TypeScript — 3 لائن کوڈ۔ سٹریمنگ، ٹول کالنگ، OpenAI + Anthropic API کے تمام پیرامیٹرز۔ Claude Code براہ راست /v1/messages کے ذریعے کام کرتا ہے۔ شروع میں 10M مفت ٹوکنز۔

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

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

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