Skip to main content

Crate anyllm_openai_compat

Crate anyllm_openai_compat 

Source
Expand description

Reusable OpenAI-compatible adapter toolkit for anyllm provider authors.

Use this crate when building a new anyllm provider crate for an upstream API that is close enough to OpenAI’s Chat Completions shape that wire translation, SSE parsing, and response conversion can be shared. It is not primarily intended for end-user application code; first-party provider crates (anyllm-openai, anyllm-cloudflare-worker) consume it.

See providers for pre-configured factories and the crate README for the intended adapter shape, observability notes, and auth contracts.

use anyllm_openai_compat::providers::Cloudflare;

let provider = Cloudflare::new("cf-account-id", "cf-api-token")?;

Modules§

providers
Pre-configured provider factories for common OpenAI-compatible APIs.

Structs§

ChatCompletionRequest
ChatCompletionResponse
EmbeddingData
EmbeddingRequestOptions
Wire-level extras applied to the OpenAI-style embedding request.
EmbeddingsRequest
OpenAI-style embeddings request wire shape.
EmbeddingsResponse
OpenAI-style embeddings response wire shape.
EmbeddingsUsage
Provider
A generic OpenAI-compatible chat provider.
ProviderBuilder
Builder for configuring a Provider.
RequestOptions
SseState
TransportConfig

Enums§

OpenAIReasoningEffort
OpenAI-compatible reasoning effort levels.

Functions§

extract_request_id
extract_retry_after
from_api_response
from_embeddings_response
Convert an OpenAI-style embeddings response into the portable EmbeddingResponse.
map_http_error
map_response_deserialize_error
map_stream_error
map_transport_error
parse_finish_reason
process_sse_data
send_chat_completion_request
send_embeddings_request
Generic HTTP dispatch for sending an OpenAI-style embeddings request body via a caller-supplied send future. Mirrors crate::send_chat_completion_request.
sse_to_stream
to_chat_completion_request
to_embeddings_request
Convert an anyllm EmbeddingRequest into the OpenAI-style wire shape.