Galon Cloud
Galon API v1

/ai/chat/completions

Base URL https://api.galon.ai/v1 · export GALON_API_BASE="https://api.galon.ai/v1"

POST /ai/chat/completions

Generate a response (chat completions compatible)

Scope ai:inference. Available on request: served only when Galon AI is open to the account (404 otherwise). No provider name is returned. Idempotency-Key required; reservation against the balance BEFORE the call (402 if the balance does not cover it). stream: true returns text/event-stream (usage in the last chunk) when the model publishes it; tools, response_format and images only for a model that publishes the capability.

API key (Bearer), on the public API endpoint.

Parameters

NameInTypeDescription
Idempotency-Keyheaderstring · required

Request body

application/json

FieldTypeDescription
modelstring · required
messagesarray<object> · required
max_tokensinteger
temperaturenumber
top_pnumber
stopany
streamboolean
seedinteger
toolsarray<object>
tool_choiceany
response_formatobject

Responses

StatusDescriptionBody
200Response in chat completions format (or SSE stream)object
400Unsupported field: code, field and message say what to correctError
402Insufficient balanceError
403scope_missingError
429Request quota reachedError
503model_temporarily_unavailableError
401Key missing or invalidError

Examples

curl

curl -X POST "$GALON_API_BASE/ai/chat/completions" \
  -H "Authorization: Bearer $GALON_API_KEY" \
  -H "Idempotency-Key: <unique-key>" \
  -H "Content-Type: application/json" \
  -d '{"model": "<id from GET /ai/models>", "messages": [{"role": "user", "content": "Hello"}]}'

Node.js (SDK)

import { Galon } from "galon";

const galon = new Galon(process.env.GALON_API_KEY);
const result = await galon.ai.chat({"model": "<id from GET /ai/models>", "messages": [{"role": "user", "content": "Hello"}]}, { idempotencyKey: "<unique-key>" });

Python (SDK)

from galon import Galon

galon = Galon()  # reads GALON_API_KEY
result = galon.ai.chat({"model": "<id from GET /ai/models>", "messages": [{"role": "user", "content": "Hello"}]}, idempotency_key="<unique-key>")