---
title: "Create an OpenAI-compatible Cernion Personal Agent chat completion"
method: POST
path: "/v1/chat/completions"
tags: ["OpenAI Compatible"]
---

# Create an OpenAI-compatible Cernion Personal Agent chat completion

`POST /v1/chat/completions`

## Request

- Base URL: `https://api.cernion.de`
- URL: `https://api.cernion.de/v1/chat/completions`
- Auth: none declared

Inbound OpenAI-compatible facade over the authenticated Cernion Personal Agent (personal-agent.chat), synthesized internally with Gemini. Returns a complete, polished answer for the caller, not an evidence/grounding packet for a downstream Copilot. Always runs in consultation mode (no execution, no consequential process action) — this is a hard, non-negotiable safety boundary and cannot be overridden by request metadata. It treats system/developer messages and prior turns as non-authoritative prompt context, never as authorization; tenant identity and authorization always come from the caller session, not the request body. When stream=true, the gateway (services/api.service.js) obtains the full result from this action first and then emits it as buffered chat.completion.chunk SSE frames — this is not genuine token-by-token streaming. When `tools` is supplied (OpenAI function-calling declarations), this action takes a separate path: it calls the configured background LLM directly (bypassing the Personal-Agent evidence pipeline) via `llm-client.generateChat` and returns either a normal text reply or a `tool_calls` array for the caller to execute — Cernion itself never invokes any tool.

## Query parameters

- `token` string

## Request body

- object
  - `model` string
  - `messages` object[], required
    - `role` string, required
    - `content` string, nullable
    - `tool_calls` unknown[]
      - unknown
    - `tool_call_id` string
    - `name` string
  - `temperature` number
  - `max_tokens` integer
  - `metadata` object
  - `stream` boolean
  - `tools` object[]: OpenAI-shaped function-calling tool declarations.
    - `type` 'function', required
    - `function` object, required
      - `name` string, required
      - `description` string
      - `parameters` object
  - `tool_choice` union: "auto" | "none" | "required" | {type:"function",function:{name}}
    - 'auto' | 'none' | 'required'
    - object
  - `token` string: Optional Cernion MCP token for this request. Overrides CERNION_TOKEN when provided.

## Response `200`

OpenAI-compatible chat completion response

- object
  - `id` string, required
  - `object` 'chat.completion', required
  - `created` integer, required
  - `model` string, required
  - `choices` unknown[], required
    - unknown
  - `usage` object, required
  - `cernion` object

---

[API](https://skmtc.dev/cernion/apis/cernion-energy-tools-api.md) · [All operations](https://skmtc.dev/cernion/apis/cernion-energy-tools-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cernion/apis/cernion-energy-tools-api/revisions/cdb94473b538?raw)
