A provider is data: an id, the wire api its adapter implements, a base URL, how to find a
credential and its models. auth names environment variables (or is a function returning a
secret handle) and is resolved per request.
Arguments
- id
Provider id,
^[a-z0-9][a-z0-9-]*$.- api
Wire api (the name of an adapter), for example
"openai-completions".- base_url
Endpoint base URL.
- auth
Character vector of environment-variable names, a function, or
NULL.- models
List of model records (each with at least
id). A reasoning model (reasoning = TRUE) lists the levels it accepts inthinking_levels, a subset of"off","minimal","low","medium","high","xhigh"and"max"; without it"off"to"high"is assumed. A requested level the model lacks becomes the nearest one it has, with a message. A level goes to the API as an effort name, or as a token budget withinminandmaxfor a record withthinking_budget = list(min = , max = )and nothinking_effort = TRUE. A record'spricesis a data frame or a list of price records:inputandoutputin USD per million tokens, optionalcache_read,cache_write_5m,cache_write_1h,from(a"YYYY-MM-DD"date) andtier("default", or">Nk"for prompts above N thousand tokens, such as">200k"); it is checked here, and without it the cost is unknown.- compat
Named list of compatibility switches for the adapter (for
api = "bedrock-converse",region: the AWS region requests are signed for).- type
"chat","classifier"(System 1) or"cli".- headers
Named list of non-secret header strings.
- discover
function()returning a data frame withid, a list of sparse model records (at leastid), orNULLwhen unsupported. Runs only ongptr_models(provider = , refresh = TRUE), after consent. An empty listing is a successful result; an error keeps prior catalog entries. Report only actual capabilities and limits.- status
function()reporting cached provider status, orNULL.- aliases
Alternative names of the provider.
- local
Endpoint locality hint: a model id written in for a local server gets no tool calls. Resolved model locality is checked separately: a loopback server may route inference to a remote model.
- offline
TRUEwhen no remote model is called (test providers).- rate
list(requests_per_s, tokens_per_s)static limits, orNULL.
Examples
gptr_provider("corp", api = "openai-completions", base_url = "https://llm.corp.example/v1",
auth = "CORP_LLM_KEY", models = list(list(id = "corp-large", context = 128000)))
#> <gptr_provider corp>
#> id: corp
#> api: openai-completions
#> base_url: https://llm.corp.example/v1
#> auth: CORP_LLM_KEY
#> models: <list of 1>
#> compat: <list of 0>
#> type: chat
#> headers: <list of 0>
#> aliases:
#> local: FALSE
#> offline: FALSE
#> api_version: 1.0
# Amazon Bedrock's Converse API through a SigV4 gateway (region and endpoint are record data):
# the IAM key pair is read from AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (and
# AWS_SESSION_TOKEN when set); gptr_env(aliases = ...) maps other names onto them. Thinking
# levels are sent only to a model whose record declares `owner = "anthropic"`: as adaptive
# thinking with an effort, or as a token budget when the record gives a `thinking_budget`;
# other models get no thinking, with a message. The bedrock-converse adapter does not request
# prompt caching, so each request sends the full prompt at the uncached rate.
gptr_provider("gateway", api = "bedrock-converse", base_url = "https://ai.corp.example/awsai",
auth = "AWS_SECRET_ACCESS_KEY", compat = list(region = "us-west-2"),
models = list(list(id = "us.anthropic.claude-opus-4-8", tool_call = TRUE,
reasoning = TRUE, owner = "anthropic",
thinking_effort = TRUE)))
#> <gptr_provider gateway>
#> id: gateway
#> api: bedrock-converse
#> base_url: https://ai.corp.example/awsai
#> auth: AWS_SECRET_ACCESS_KEY
#> models: <list of 1>
#> compat: <list of 1>
#> type: chat
#> headers: <list of 0>
#> aliases:
#> local: FALSE
#> offline: FALSE
#> api_version: 1.0