ServicesAI Services

OpenAI-Compatible Chat Completions

Call Downcity's unified LanguageModelV3 path with the OpenAI SDK or curl.

Endpoint: POST /v1/ai/chat/completions.

const openai = new OpenAI({
  baseURL: "https://federation.example/v1/ai",
  apiKey: "user-token",
});

const result = await openai.chat.completions.create({
  model: "gpt-5.6-luna",
  messages: [{ role: "user", content: "hello" }],
  stream: true,
});

The request follows one path:

OpenAI request
  -> OpenAIChatCompletionsAdapter
  -> LanguageModelV3CallOptions
  -> AIService fallback/reasoning
  -> AIChannel.stream()
  -> OpenAI JSON or SSE

The adapter supports system, user, assistant, and tool messages; text and image URLs; function tools, tool choice, reasoning_effort, common sampling parameters, and stream: true.

Client providerOptions never reach the upstream. Private upstream options must be configured by ai_sdk_provider_options on the AIChannel or AIModelSpec.