% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api_openrouter.R
\name{openrouter_chat}
\alias{openrouter_chat}
\title{Send LLM Messages to the OpenRouter Chat API}
\usage{
openrouter_chat(
  .llm,
  .model = "anthropic/claude-sonnet-4-6",
  .max_tokens = 2048,
  .temperature = NULL,
  .top_p = NULL,
  .frequency_penalty = NULL,
  .presence_penalty = NULL,
  .stop = NULL,
  .stream = FALSE,
  .json_schema = NULL,
  .tools = NULL,
  .tool_choice = NULL,
  .provider = NULL,
  .route = NULL,
  .models = NULL,
  .api_url = "https://openrouter.ai",
  .timeout = 60,
  .verbose = FALSE,
  .dry_run = FALSE,
  .max_tries = 3,
  .max_tool_rounds = 10
)
}
\arguments{
\item{.llm}{An \code{LLMMessage} object containing the conversation history.}

\item{.model}{The model identifier to use (default: \code{"google/gemini-2.5-flash"}).
Any model available on OpenRouter can be used.}

\item{.max_tokens}{Maximum number of tokens in the response (default: 2048).}

\item{.temperature}{Controls randomness (0–2, optional).}

\item{.top_p}{Nucleus sampling parameter (0–1, optional).}

\item{.frequency_penalty}{Penalizes repeated tokens (-2 to 2, optional).}

\item{.presence_penalty}{Encourages new topics (-2 to 2, optional).}

\item{.stop}{One or more stop sequences (optional).}

\item{.stream}{Logical; if TRUE, streams the response (default: FALSE).}

\item{.json_schema}{A JSON schema object for structured output (default: NULL).}

\item{.tools}{Either a single TOOL object or a list of TOOL objects for tool calls.}

\item{.tool_choice}{Tool-calling behavior: \code{"none"}, \code{"auto"}, or \code{"required"} (optional).}

\item{.provider}{A named list of OpenRouter provider preferences, e.g.
\code{list(order = c("Anthropic", "AWS Bedrock"), allow_fallbacks = TRUE)} (optional).}

\item{.route}{OpenRouter routing strategy; \code{"fallback"} routes to the next model if
the primary is unavailable (optional).}

\item{.models}{A character vector of model IDs to use as fallbacks when the primary
model is unavailable (optional). Used together with \code{.route = "fallback"}.}

\item{.api_url}{Base URL for the OpenRouter API (default: \code{"https://openrouter.ai"}).}

\item{.timeout}{Request timeout in seconds (default: 60).}

\item{.verbose}{If TRUE, displays additional information after the API call (default: FALSE).}

\item{.dry_run}{If TRUE, returns the request object without executing it (default: FALSE).}

\item{.max_tries}{Maximum retries (default: 3).}

\item{.max_tool_rounds}{Maximum number of tool use iterations (default: 10).}
}
\value{
A new \code{LLMMessage} object containing the original messages plus the assistant's response.
}
\description{
Sends a message history to the OpenRouter API, which provides access to hundreds
of models from different providers through a single OpenAI-compatible endpoint.
}
