GenAI.Provider.OpenRouter (Noizu Labs, GenAI Wrapper v0.3.11)

Copy Markdown View Source

OpenRouter inference provider (https://openrouter.ai/api/v1).

OpenAI-compatible chat and GET /models. Bearer auth from config :genai, :openrouter, api_key: (OPENROUTER_API_KEY). Optional attribution headers: http_referer (HTTP-Referer) and app_title (X-OpenRouter-Title / X-Title).

Summary

Functions

Bearer token (api_key / OPENROUTER_API_KEY).

OpenAI-compatible API root (…/api/v1). Per-request :base_url still wins.

Return config_key inference provide application config stored under :genai entry

Obtain map of effective settings: settings, model_settings, provider_settings, config_settings, etc.

Prepare endpoint and method to make inference call to

Retrieves models from OpenRouter GET /api/v1/models.

Prepare request body to be passed to inference call.

Build and run inference thread

Build and run inference thread in streaming mode

Functions

api_key(settings \\ [], options \\ [])

Bearer token (api_key / OPENROUTER_API_KEY).

base_url(settings \\ [])

OpenAI-compatible API root (…/api/v1). Per-request :base_url still wins.

chat(messages, tools, settings)

chat(model, messages, tools, hyper_parameters, provider_settings \\ [], context \\ nil, options \\ nil)

Callback implementation for GenAI.InferenceProviderBehaviour.chat/7.

config_key()

Return config_key inference provide application config stored under :genai entry

default_encoder()

effective_settings(model, session, context, options \\ nil)

Obtain map of effective settings: settings, model_settings, provider_settings, config_settings, etc.

endpoint(model, settings, session, context, options \\ nil)

Prepare endpoint and method to make inference call to

generate_media(request, options)

Callback implementation for GenAI.InferenceProviderBehaviour.generate_media/2.

headers(options)

headers(model, settings, session, context, options \\ nil)

Prepare request headers

models(settings \\ [])

Retrieves models from OpenRouter GET /api/v1/models.

request_body(model, messages, tools, settings, session, context, options \\ nil)

Prepare request body to be passed to inference call.

run(session, context, options \\ nil)

Build and run inference thread

standardize_model(model)

Callback implementation for GenAI.InferenceProviderBehaviour.standardize_model/1.

stream(session, context, options \\ nil)

Build and run inference thread in streaming mode

supported_modalities()

Callback implementation for GenAI.InferenceProviderBehaviour.supported_modalities/0.