LemonAi. Providers. OpenAICompletions
(lemon_ai v0.1.0)
View Source
OpenAI Completions API provider.
This provider implements the OpenAI Chat Completions API format, which is used by many OpenAI-compatible services including:
- OpenAI (api.openai.com)
- Groq (api.groq.com)
- Mistral (api.mistral.ai)
- xAI/Grok (api.x.ai)
- Cerebras (api.cerebras.ai)
- OpenRouter (openrouter.ai)
- Local servers (llama.cpp, etc.)
SSE Format
The API returns Server-Sent Events (SSE) with data: lines containing JSON chunks:
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":" world"}}]}
data: [DONE]Compatibility Settings
Different providers have varying support for OpenAI features. The model.compat
field can override auto-detection:
supports_store- Whether to sendstore: falsesupports_developer_role- Use "developer" vs "system" role for reasoning modelssupports_reasoning_effort- Whetherreasoning_effortparameter worksmax_tokens_field- "max_completion_tokens" (default) or "max_tokens"requires_tool_result_name- Includenamein tool results (Mistral)requires_assistant_after_tool_result- Add synthetic assistant message after tool resultsrequires_thinking_as_text- Convert thinking blocks to plain textrequires_mistral_tool_ids- Normalize tool IDs to 9 alphanumeric chars