Документация API go2llm

Chat Completions

Используйте POST /v1/chat/completions только для моделей, у которых GET /v1/models содержит endpoint chat.completions.

curl https://go2llm.tech/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "MODEL_ID_ИЗ_КАТАЛОГА",
    "messages": [
      { "role": "system", "content": "Отвечай кратко." },
      { "role": "user", "content": "Скажи OK" }
    ],
    "max_tokens": 120,
    "stream": false
  }'

JavaScript

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://go2llm.tech/v1",
});

const response = await client.chat.completions.create({
  model: process.env.GO2LLM_MODEL,
  messages: [{ role: "user", content: "Скажи OK" }],
});

console.log(response.choices[0].message.content);

Фактическое списание в USD находится в response.usage.cost_usd.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://go2llm.tech/v1",
)

response = client.chat.completions.create(
    model=os.environ["GO2LLM_MODEL"],
    messages=[{"role": "user", "content": "Скажи OK"}],
)

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

Передайте stream: true для SSE: финальный usage-блок содержит cost_usd. Image input разрешён только моделям, у которых GET /v1/models содержит image в modalities.input; у остальных используйте модель из vision_companion. Audio, video, PDF и другие binary blocks вернут unsupported_content_type.