pub struct BackendConfig {
pub name: String,
pub endpoint: String,
pub model: String,
pub model_path: Option<String>,
pub tiers: Vec<Tier>,
pub kind: BackendKind,
pub api: OpenAiApi,
pub api_key_file: Option<String>,
pub api_key_env: Option<String>,
}Expand description
A single inference backend entry.
Two ways to define one: an inline [[backends]] array element in
config.toml, or a per-file drop-in ~/.newt/backends/<name>.toml (the
filename stem is the name, so a drop-in omits it). name and tiers
therefore default — a minimal drop-in is just endpoint + model.
Fields§
§name: StringBackend name. For a per-file drop-in this is overwritten by the filename stem, so the file body may omit it.
endpoint: StringHTTP endpoint URL (Ollama / OpenAI). Defaulted so a kind = "embedded"
backend — which runs in-process and has no URL — can omit it.
model: String§model_path: Option<String>For kind = "embedded": the local GGUF model file (the in-process engine
has no endpoint). ~/ is expanded at use. Ignored for HTTP backends.
tiers: Vec<Tier>§kind: BackendKindWhich wire protocol this backend speaks. Defaults to ollama
so configs written before this field existed keep working.
api: OpenAiApiFor kind = "openai": which OpenAI HTTP surface to use
(chat_completions default, or responses for models served only on
/v1/responses). Ignored for Ollama. The agent loop also auto-falls-back
to responses if chat/completions 404s with the responses-only error.
api_key_file: Option<String>Optional path to a file whose first non-empty line is a bearer
token, sent as Authorization: Bearer <token> by
OpenAI-compatible backends. A leading ~/ is expanded to the
home directory. Keeping the secret in a file (rather than inline
in the config) keeps tokens out of version control.
api_key_env: Option<String>Optional environment variable name holding a bearer token. Takes
precedence over api_key_file when both
resolve to a non-empty value.
Implementations§
Source§impl BackendConfig
impl BackendConfig
Sourcepub fn resolve_api_key(&self) -> Option<String>
pub fn resolve_api_key(&self) -> Option<String>
Resolve this backend’s bearer token, if any.
Checks api_key_env first (environment
variable), then api_key_file (first
non-empty line of the file, trimmed). Returns None when neither
is configured or neither resolves to a non-empty value.
Trait Implementations§
Source§impl Clone for BackendConfig
impl Clone for BackendConfig
Source§fn clone(&self) -> BackendConfig
fn clone(&self) -> BackendConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BackendConfig
impl Debug for BackendConfig
Source§impl<'de> Deserialize<'de> for BackendConfig
impl<'de> Deserialize<'de> for BackendConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BackendConfig
impl RefUnwindSafe for BackendConfig
impl Send for BackendConfig
impl Sync for BackendConfig
impl Unpin for BackendConfig
impl UnsafeUnpin for BackendConfig
impl UnwindSafe for BackendConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more