Liking cljdoc? Tell your friends :D

repling.agent.provider


provider-openai-compatibleclj

(provider-openai-compatible
  {:keys [name endpoint model] :or {name "openai-compatible"} :as options})

Builds a provider that talks to an OpenAI-compatible chat completions endpoint.

options accepts:

  • required :endpoint - chat completions URL
  • required :model - default model name
  • optional :name - provider display name, defaults to "openai-compatible"
  • optional :api-key - raw API key string
  • optional :api-key-env - environment variable name containing the API key
  • optional :api-key-fn - zero-arg function that returns the API key string
  • optional :timeout-ms - request timeout in milliseconds
  • optional :max-retries - retry count for retryable HTTP responses such as 429, 502, 503, and 504; defaults to 3
  • optional :retry-delay-ms - base delay for retryable responses when the server does not send Retry-After; defaults to 20000
  • optional :pricing - either a direct pricing map or a map of model IDs to pricing maps. Pricing maps use :input-per-1m-usd, :output-per-1m-usd, and optional :cached-input-per-1m-usd
  • optional :headers - extra HTTP headers map
  • optional :default-body - extra request body fields merged into every call

Request maps sent to the returned provider may include :prompt or :messages, plus chat-completions fields like :temperature, :top-p, :max-tokens, :presence-penalty, :frequency-penalty, :stop, :n, :tools, :tool-choice, :response-format, :stream, and :metadata.

When :model-tools is present in the request, those model-facing tools are exposed as OpenAI/GitHub function tools and tool_calls responses are normalized back into :tool-requests for the session loop. Malformed tool-call arguments are surfaced back through the session loop as tool errors so the model can retry.

Successful responses include :usage when the provider returns token usage data, and include local-only :token-counts and :cost when usage data is available. :cost additionally needs pricing information. This bookkeeping is not sent back to the model in later turns.

Builds a provider that talks to an OpenAI-compatible chat completions endpoint.

`options` accepts:
- required `:endpoint` - chat completions URL
- required `:model` - default model name
- optional `:name` - provider display name, defaults to
  `"openai-compatible"`
- optional `:api-key` - raw API key string
- optional `:api-key-env` - environment variable name containing the API key
- optional `:api-key-fn` - zero-arg function that returns the API key string
- optional `:timeout-ms` - request timeout in milliseconds
- optional `:max-retries` - retry count for retryable HTTP responses such as
  `429`, `502`, `503`, and `504`; defaults to `3`
- optional `:retry-delay-ms` - base delay for retryable responses when the
  server does not send `Retry-After`; defaults to `20000`
- optional `:pricing` - either a direct pricing map or a map of model IDs to
  pricing maps. Pricing maps use `:input-per-1m-usd`,
  `:output-per-1m-usd`, and optional `:cached-input-per-1m-usd`
- optional `:headers` - extra HTTP headers map
- optional `:default-body` - extra request body fields merged into every call

Request maps sent to the returned provider may include `:prompt` or
`:messages`, plus chat-completions fields like `:temperature`, `:top-p`,
`:max-tokens`, `:presence-penalty`, `:frequency-penalty`, `:stop`, `:n`,
`:tools`, `:tool-choice`, `:response-format`, `:stream`, and `:metadata`.

When `:model-tools` is present in the request, those model-facing tools are
exposed as OpenAI/GitHub function tools and `tool_calls` responses are
normalized back into `:tool-requests` for the session loop. Malformed
tool-call arguments are surfaced back through the session loop as tool
errors so the model can retry.

Successful responses include `:usage` when the provider returns token usage
data, and include local-only `:token-counts` and `:cost` when usage data is
available. `:cost` additionally needs pricing information. This bookkeeping
is not sent back to the model in later turns.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close