Getting Started with OpenAI SDK
To start using Emby’s Chat Completions API, you’ll need to install the OpenAI SDK and set up your API key with the environment variableEMBY_API_KEY.
Performing a Basic Chat Completion
The simplest way to use the Chat Completions API is to send a list of messages and receive a single response. Messages are provided in chronological order, with each message containing a role (“system”, “user”, or “assistant”) and content.Performing a Chat Completion with a Stop Sequence
Stop sequences allow you to control where the model should stop generating. When the model encounters any of the specified stop sequences, it will halt generation at that point. This is useful when you need responses to end at specific points.Performing an Async Chat Completion
For applications that need to maintain responsiveness while waiting for completions, you can use the asynchronous client. This lets you make non-blocking API calls using Python’s asyncio framework.Structured Outputs and JSON
Need reliable, type-safe JSON responses that match your exact schema? Emby’s Structured Outputs feature is designed so that model responses strictly conform to your JSON Schema without validation or retry logic. For complete guides on implementing structured outputs with JSON Schema or using JSON Object Mode, see our structured outputs documentation. Key capabilities:- JSON Schema enforcement: Responses match your schema exactly
- Type-safe outputs: No validation or retry logic needed
- Programmatic refusal detection: Handle safety-based refusals programmatically
- JSON Object Mode: Basic JSON output with prompt-guided structure

