Liking cljdoc? Tell your friends :D

litellm.config

Configuration registry for provider/model switching

Configuration registry for provider/model switching
raw docstring

clear-registry!clj

(clear-registry!)

Clear all registered configurations (useful for testing)

Clear all registered configurations (useful for testing)
sourceraw docstring

config-registryclj

source

get-configclj

(get-config config-name)

Get a registered configuration by name

Get a registered configuration by name
sourceraw docstring

list-configsclj

(list-configs)

List all registered configuration names

List all registered configuration names
sourceraw docstring

register!clj

(register! config-name config-map)

Register a provider configuration with a keyword name.

Configuration can be:

  • Simple: {:provider :openai :model "gpt-4" :config {...}}
  • With router: {:router (fn [request] {...}) :config {...}}
  • Multi-provider: {:router (fn [request] {...}) :configs {:openai {...} :anthropic {...}}}

Examples: (register! :fast {:provider :openai :model "gpt-4o-mini" :config {:api-key "..."}})

(register! :smart {:router (fn [req] (if (> (count (:messages req)) 10) {:provider :anthropic :model "claude-3-opus"} {:provider :openai :model "gpt-4o-mini"})) :configs {:openai {:api-key "..."} :anthropic {:api-key "..."}}})

Register a provider configuration with a keyword name.

Configuration can be:
- Simple: {:provider :openai :model "gpt-4" :config {...}}
- With router: {:router (fn [request] {...}) :config {...}}
- Multi-provider: {:router (fn [request] {...}) :configs {:openai {...} :anthropic {...}}}

Examples:
  (register! :fast {:provider :openai :model "gpt-4o-mini" :config {:api-key "..."}})
  
  (register! :smart {:router (fn [req] 
                               (if (> (count (:messages req)) 10)
                                 {:provider :anthropic :model "claude-3-opus"}
                                 {:provider :openai :model "gpt-4o-mini"}))
                     :configs {:openai {:api-key "..."} 
                              :anthropic {:api-key "..."}}})
sourceraw docstring

register-with-validation!clj

(register-with-validation! config-name config-map)

Register a configuration with validation

Register a configuration with validation
sourceraw docstring

resolve-configclj

(resolve-config config-name request)

Resolve a configuration, applying router function if present.

Returns a map with :provider, :model, and :config keys.

If config has a :router function, it will be called with the request to determine provider/model dynamically.

Resolve a configuration, applying router function if present.

Returns a map with :provider, :model, and :config keys.

If config has a :router function, it will be called with the request
to determine provider/model dynamically.
sourceraw docstring

unregister!clj

(unregister! config-name)

Remove a configuration from the registry

Remove a configuration from the registry
sourceraw docstring

validate-configclj

(validate-config config-map)

Validate a configuration map

Validate a configuration map
sourceraw 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