% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api_openai.R
\name{openai_chat}
\alias{openai_chat}
\title{Send LLM Messages to the OpenAI Responses API}
\usage{
openai_chat(
  .llm,
  .model = "gpt-5.5",
  .max_output_tokens = NULL,
  .temperature = NULL,
  .seed = NULL,
  .stream = FALSE,
  .timeout = 60,
  .verbose = FALSE,
  .json_schema = NULL,
  .max_tries = 3,
  .dry_run = FALSE,
  .reasoning_effort = NULL,
  .tools = NULL,
  .tool_choice = NULL,
  .max_tool_rounds = 10,
  .stateful = FALSE
)
}
\arguments{
\item{.llm}{An \code{LLMMessage} object containing the conversation history.}

\item{.model}{The model identifier (default: \code{"gpt-5.5"}).}

\item{.max_output_tokens}{Maximum tokens to generate (caps reasoning + completion).}

\item{.temperature}{Sampling temperature (0-2).}

\item{.seed}{Seed for deterministic sampling.}

\item{.stream}{If TRUE, stream output to console (default: FALSE).}

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

\item{.verbose}{Print rate-limit info after the call (default: FALSE).}

\item{.json_schema}{A tidyllm schema or ellmer type for structured output.}

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

\item{.dry_run}{If TRUE, return the request object without sending (default: FALSE).}

\item{.reasoning_effort}{For o-series models: \code{"low"}, \code{"medium"}, or \code{"high"}.}

\item{.tools}{A TOOL object or list of TOOL objects for function calling.}

\item{.tool_choice}{Tool selection behavior: \code{"none"}, \code{"auto"}, or \code{"required"}.}

\item{.max_tool_rounds}{Maximum tool-loop iterations (default: 10).}

\item{.stateful}{If \code{TRUE}, use \code{previous_response_id} to pass conversation context
server-side instead of re-sending full message history. Falls back to full-history
mode silently when no previous response ID is available (first turn or prior turn
used a different provider), and with a warning if the server rejects the stored ID
(e.g., expired context). Default: \code{FALSE}.}
}
\value{
A new \code{LLMMessage} object with the assistant's response appended.
}
\description{
Sends a message history to the OpenAI Responses API (\code{POST /v1/responses}) and
returns the assistant's reply. Supports streaming, tool use, structured output,
and reasoning models (o-series) via \code{.reasoning_effort}.
}
