services/api/openai/completions
OpenAI-compatible chat completions client.
Works with OpenAI, DeepSeek, and any provider that speaks the
/v1/chat/completions API.
Synchronous (no streaming). Tool calling supported.
Values
pub fn chat(
client: client.Client,
messages: List(message.Message),
tools: List(tool_def.ToolDefinition),
) -> Result(response.ChatResponse, client.ClientError)
pub fn chat_with_retry(
client: client.Client,
messages: List(message.Message),
tools: List(tool_def.ToolDefinition),
max_retries: Int,
) -> Result(response.ChatResponse, client.ClientError)
pub fn classify_error(
status: Int,
body: String,
) -> client.ClientError
Classify an HTTP status + body into a structured client.ClientError variant. Only call this for error responses (non-2xx status codes).
pub fn is_retryable(error: client.ClientError) -> Bool
Returns True if the error is retryable (backoff + retry makes sense).
pub fn llm_client() -> behaviours.LLMClient
pub fn message_to_json(msg: message.Message) -> String
pub fn new(api_key: String) -> client.Client
pub fn parse_response(
body: String,
) -> Result(response.ChatResponse, client.ClientError)
pub fn parse_retry_after(body: String) -> Int
Parse a Retry-After value in milliseconds from an error response body. Looks for “retry after” patterns and plain integer values in the body. Returns 0 if no Retry-After hint is found.
pub fn service() -> service.Service
pub fn should_compress(error: client.ClientError) -> Bool
Returns True if context compression should be triggered before retry.
pub fn tool_to_json(tool: tool_def.ToolDefinition) -> String
pub fn with_base_url(
c: client.Client,
url: String,
) -> client.Client
pub fn with_model(
c: client.Client,
model: String,
) -> client.Client