Guide / OpenAI compatibility

How to use a decentralized AI API with the OpenAI SDK

A practical guide to connecting Python, JavaScript, agents, and automation tools to an OpenAI-compatible decentralized AI API.

Direct answer

An OpenAI-compatible decentralized AI API lets an existing OpenAI SDK client use decentralized inference by changing three settings: the base URL, API key, and model name. Request and response shapes remain familiar.

Python setup

from openai import OpenAI
import os
client = OpenAI(
    base_url="https://api.gonka.broker/v1",
    api_key=os.environ["GONKA_API_KEY"],
)
reply = client.chat.completions.create(
    model="gonka-auto",
    messages=[{"role":"user","content":"Explain decentralized inference"}],
)
print(reply.choices[0].message.content)

JavaScript setup

const response = await fetch("https://api.gonka.broker/v1/chat/completions", {
  method: "POST",
  headers: {"Authorization": `Bearer ${{process.env.GONKA_API_KEY}}`, "Content-Type": "application/json"},
  body: JSON.stringify({model: "gonka-auto", messages: [{role: "user", content: "Hello"}]})
});

Production checklist

  1. Store the API key in a server-side environment variable.
  2. Set request and output-token limits.
  3. Use bounded retries for temporary 429 and 5xx responses.
  4. Record request IDs rather than prompt content in operational logs.
  5. Monitor usage and keep a prepaid spending ceiling.

Related integration guides

See the focused setup guides for Hermes Agent, OpenClaw, and n8n.


Next step: Create an account or read the integration docs.