OpenAI Compatibility
OpenAI compatibility
OpenAI Compatibility
Text chat through the official OpenAI SDK
POST
OpenAI Compatibility
Elumenta provides OpenAI-compatible endpoints for text chat:
Copy the entire example and replace only the API key:
The
The
POST /v1/chat/completions— create a response, including streaming responses;GET /v1/models— list available text models in OpenAI format.
Access
Use the samenb_... API key that you use with /api/v2; you do not need a separate key. API access requires the Advanced plan or higher (t2_advanced or vip, level 3). Lower plans receive a 403 response explaining the required plan.
Complete Python example
Install the official SDK:system, user, and assistant roles are supported, as are temperature and max_tokens. The final message must use the user role.
Streaming
Passstream=True to consume response chunks as they arrive:
elumenta object arrives in the final stream chunk. Its tokens_spent and balance fields are included only when their values are known, so read them with .get() as shown above. The object can be empty, for example when streaming reconciliation does not run for a web session.
Call cost
Each synchronous response contains two adjacent objects:usage— exactly the three standard OpenAI fields:prompt_tokens,completion_tokens, andtotal_tokens;elumenta.tokens_spent— the tkn actually charged for this call after reconciliation with the provider’s real usage, when known;elumenta.balance— the balance remaining after the charge, when known.
elumenta may be an empty object when neither value is known. In streaming mode Elumenta cannot completely populate usage, because the completion event does not contain the input and output token counts. To keep the response shape consistent in both modes, cost fields are placed alongside usage in elumenta, rather than inside usage.
For synchronous HTTP responses, X-RateLimit-Limit contains the request limit and X-Token-Balance contains the token balance. Streaming responses do not include X-Token-Balance: headers are sent before the stream finishes, while the final charge is not yet known. Read the current balance from elumenta.balance in the final chunk instead.
List models
GET /v1/models follows the OpenAI format and therefore does not include pricing; this is how the OpenAI specification is structured. Elumenta prices are available from GET /api/v2/models.
For images, video, audio, and other capabilities, use the unified Elumenta API.
