Abschnitte der Wissensbasis ▾

Navigation

▸ Hier starten Nach Rollen

Kategorien

Werkzeuge 52
Glossar 12

Tools

API Schnellstart — curl, Python, TypeScript

JoinGonka Gateway bietet eine OpenAI + Anthropic kompatible API für das dezentrale Gonka-Netzwerk. Jeder Code, der für die OpenAI API (/v1/chat/completions) geschrieben wurde, funktioniert mit Gonka — Sie müssen lediglich die base_url und den api_key anpassen. Tools für die Anthropic API (Claude Code) können über /v1/messages direkt ohne Proxy verbunden werden.

In diesem Artikel finden Sie fertige Codebeispiele für die drei gängigsten Werkzeuge: curl (Befehlszeile), Python und TypeScript/Node.js (OpenAI-Format). Für das Anthropic-Format siehe die Claude Code-Anleitung.

Was Sie benötigen: Einen JoinGonka API-Schlüssel (Format jg-xxx). Holen Sie ihn sich kostenlos auf gate.joingonka.ai/register zusammen mit einem Bonus von 3M Token.

curl — Abfrage vom Terminal

Der schnellste Weg, die API zu testen, ist curl:

Standardanfrage:

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 (Antwort in Teilen):

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
  }'

Die Antwort kommt im JSON-Format (Standard) oder als Server-Sent Events (Streaming) — vollständig kompatibel mit der OpenAI-API.

Python — openai SDK

Das offizielle OpenAI Python SDK funktioniert mit dem JoinGonka Gateway ohne Änderungen:

pip install openai

Standardanfrage:

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}")

Die Modelle im Netzwerk unterstützen natives Tool calling — Funktionen werden korrekt aufgerufen, ohne dass Textantworten geparst werden müssen.

TypeScript/Node.js — openai SDK

Installation:

npm install openai

Standardanfrage:

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}`);

Alle Beispiele verwenden das offizielle OpenAI SDK — zusätzliche Bibliotheken sind nicht erforderlich. Ersetzen Sie einfach base_url und api_key.

Unterstützte API-Parameter

JoinGonka Gateway unterstützt alle Standardparameter der OpenAI Chat Completions API:

ParameterTypBeschreibung
modelstringModell: MiniMaxAI/MiniMax-M2.7
messagesarrayNachrichtenverlauf (system, user, assistant)
streambooleanStreaming-Generierung (SSE). Standard: false
temperaturenumberKreativität der Antwort (0.0 — 2.0)
max_tokensintegerMaximale Antwortlänge (max: 8192, bei DeepSeek V4 Flash — 32768; standardmäßig ohne max_tokens — 1500)
toolsarrayFunktionsdefinitionen für tool calling
tool_choicestring/objectStrategie für den Funktionsaufruf

Parameter der Netzwerk-Modelle: Kontextfenster — 200K Token bei MiniMax M2.7 (380K bei DeepSeek V4 Flash, 390K bei GLM-5.3 Flash), maximale Antwort — bis zu 8192 Token (bei DeepSeek V4 Flash — bis zu 32768). Die Modellliste ist über GET /v1/models verfügbar.

Zwei Endpunkte:

  • OpenAI-Format: POST https://gate.joingonka.ai/v1/chat/completions
  • Anthropic-Format: POST https://gate.joingonka.ai/v1/messages

Authentifizierung: Authorization: Bearer jg-your-key (OpenAI) oder x-api-key: jg-your-key (Anthropic)

Das Antwortformat ist vollständig kompatibel mit OpenAI und Anthropic — jedes SDK, jede Bibliothek oder jedes Framework, das die OpenAI- oder Anthropic-API unterstützt, funktioniert mit JoinGonka Gateway ohne Änderungen. Claude Code verbindet sich direkt über das Anthropic-Format.

JoinGonka Gateway — OpenAI + Anthropic kompatible API für $0.0069/1M Token. curl, Python, TypeScript — 3 Zeilen Code. Streaming, Tool Calling, alle Parameter der OpenAI + Anthropic API. Claude Code funktioniert direkt über /v1/messages. 3M kostenlose Token zum Start.

Möchten Sie mehr erfahren?

Erkunden Sie andere Abschnitte oder beginnen Sie jetzt GNK zu verdienen.

Kostenlose Token erhalten →