chat_posit: Chat with a model hosted by Posit AI

View source: R/provider-posit.R

chat_positR Documentation

Chat with a model hosted by Posit AI

Description

[Official supported provider]

Posit AI provides access to a curated set of models for Posit subscribers.

Authentication

By default, chat_posit() authenticates with an OAuth device flow against login.posit.cloud: the first time you use it, you'll be prompted to visit a URL and enter a code. The resulting tokens are cached on disk (see httr2::req_oauth_device()) and refreshed automatically, so you should only need to do this once per machine.

Usage

chat_posit(
  system_prompt = NULL,
  base_url = "https://gateway.posit.ai",
  credentials = NULL,
  model = NULL,
  params = NULL,
  cache = c("5m", "1h", "none"),
  api_args = list(),
  api_headers = character(),
  echo = NULL
)

models_posit(base_url = "https://gateway.posit.ai", credentials = NULL)

Arguments

system_prompt

A system prompt to set the behavior of the assistant.

base_url

The base URL of the Posit AI gateway.

credentials

A zero-argument function that returns the credentials to use in place of the default OAuth device flow, either as a named list of headers or as a function that modifies the request. You should not usually need to set this.

model

The model to use for the chat (defaults to "claude-sonnet-4-6"). We regularly update the default, so we strongly recommend explicitly specifying a model for anything other than casual use. Use models_posit() to see all options.

params

Common model parameters, usually created by params().

cache

How long to cache inputs? Defaults to "5m" (five minutes). Set to "none" to disable caching or "1h" to cache for one hour. This is only supported for Claude models and is ignored for other models.

api_args

Named list of arbitrary extra arguments appended to the body of every chat API call. Combined with the body object generated by ellmer with modifyList().

api_headers

Named character vector of arbitrary extra headers appended to every chat API call.

echo

One of the following options:

  • none: don't emit any output (default when running in a function).

  • output: echo text and tool-calling output as it streams in (default when running at the console).

  • all: echo all input and output.

Note this only affects the chat() method.

Value

A Chat object.

See Also

Other chatbots: chat_anthropic(), chat_aws_bedrock(), chat_azure_openai(), chat_cloudflare(), chat_databricks(), chat_deepseek(), chat_github(), chat_google_gemini(), chat_groq(), chat_huggingface(), chat_lmstudio(), chat_mistral(), chat_ollama(), chat_openai(), chat_openai_compatible(), chat_openrouter(), chat_perplexity(), chat_portkey()

Examples

## Not run: 
chat <- chat_posit()
chat$chat("Tell me three jokes about statisticians")

## End(Not run)

ellmer documentation built on July 14, 2026, 1:07 a.m.