org.llm4s.http
Members list
Type members
Classlikes
Case-insensitive lookup over a multi-valued header map, as carried by every response type in this package.
Case-insensitive lookup over a multi-valued header map, as carried by every response type in this package.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
HttpHeaders.type
How llm4s's HTTP clients reach the network: an optional HttpProxy and the HttpTls material, read once from the llm4s.http block (Llm4sConfig.httpNetwork()) and honoured by every provider client - the JDK client in core, the openai-java and anthropic-java SDKs and the AWS SDK.
How llm4s's HTTP clients reach the network: an optional HttpProxy and the HttpTls material, read once from the llm4s.http block (Llm4sConfig.httpNetwork()) and honoured by every provider client - the JDK client in core, the openai-java and anthropic-java SDKs and the AWS SDK.
A named provider section can override it for one route with its own http block (llm4s.providers.<name>.http), whose keys take precedence over llm4s.http one by one.
HttpNetworkSettings.default - no proxy, no extra TLS material - leaves every client as it was before the setting existed: the JDK client keeps the JVM's default proxy selector.
Build one with HttpNetworkSettings.apply or HttpNetworkSettings.default and the with* setters; the constructor is private, so a new field never breaks a caller.
Value parameters
- proxy
-
the proxy to route through, or
Nonefor a direct connection - tls
-
the extra trust and client-certificate material
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
HttpNetworkSettings.type
An outbound HTTP proxy every llm4s HTTP client routes through: the llm4s.http.proxy block.
An outbound HTTP proxy every llm4s HTTP client routes through: the llm4s.http.proxy block.
llm4s.http.proxy {
url = "http://proxy.corp:3128"
username = ${?LLM4S_PROXY_USER}
password = ${?LLM4S_PROXY_PASSWORD}
nonProxyHosts = ["localhost", "*.internal"]
}
The proxy is an HTTP proxy: plain-http requests go to it in absolute form, https ones through a CONNECT tunnel. Proxy authentication is HTTP Basic; PAC files and Kerberos/NTLM are not supported.
nonProxyHosts lists the hosts reached directly. An entry is a host name or address matched exactly (localhost), a domain suffix (*.internal or .internal, which match internal itself too), a prefix (10.*), or * for every host; matching ignores case. A CIDR range is not supported. The default is the loopback addresses (HttpProxy.DefaultNonProxyHosts); setting the list replaces it.
The password is redacted in toString. Build one with HttpProxy.apply or HttpProxy.fromUrl and adjust it with the with* setters; the constructor is private, so a new field never breaks a caller.
Value parameters
- host
-
the proxy's host name or address
- nonProxyHosts
-
the hosts reached directly, not through the proxy
- password
-
the password for proxy authentication; never printed
- port
-
the proxy's port
- username
-
the user name for proxy authentication, if the proxy requires it
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
HTTP response wrapper for binary (non-text) response bodies.
HTTP response wrapper for binary (non-text) response bodies.
Use this instead of HttpResponse when the response body is binary data (e.g. image bytes) to avoid lossy charset decoding.
Value parameters
- body
-
Raw response bytes — exact wire representation, no charset conversion
- headers
-
Response headers as a multi-valued map (lowercase keys) Build one with HttpRawResponse.apply and change it with the
with*setters; the constructor andcopyare private, so a new field never breaks callers. - statusCode
-
HTTP status code
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
HttpRawResponse.type
HTTP response wrapper exposing status code, body, and headers.
HTTP response wrapper exposing status code, body, and headers.
Value parameters
- body
-
Response body as a string
- headers
-
Response headers as a multi-valued map (lowercase keys) Build one with HttpResponse.apply and change it with the
with*setters; the constructor andcopyare private, so a new field never breaks callers. - statusCode
-
HTTP status code (e.g. 200, 404)
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
HttpResponse.type
The TLS trust and client-certificate material every llm4s HTTP client uses: the llm4s.http.tls block.
The TLS trust and client-certificate material every llm4s HTTP client uses: the llm4s.http.tls block.
llm4s.http.tls {
trustStore = "/etc/pki/corp-ca.p12"
trustStorePassword = ${?LLM4S_TRUSTSTORE_PASSWORD}
keyStore = "/etc/pki/client.p12" # optional: a client certificate, for mTLS gateways
keyStorePassword = ${?LLM4S_KEYSTORE_PASSWORD}
}
The trust store's certificates are trusted '''in addition to''' the JDK's default ones, so a corporate CA that re-signs traffic is accepted without losing the public CAs. A store may be PKCS12 or JKS; the type is detected from the file. The passwords are redacted in toString.
Build one with HttpTls.default and the with* setters; the constructor is private, so a new field never breaks a caller.
Value parameters
- keyStore
-
a store holding the client certificate and its key, for mutual TLS, if any
- keyStorePassword
-
the key store's password, also used for the key; never printed
- trustStore
-
a store of extra CA certificates to trust, if any
- trustStorePassword
-
the trust store's password, if it has one; never printed
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
An HTTP response whose body has been parsed as JSON (see HttpResponse.toJson).
An HTTP response whose body has been parsed as JSON (see HttpResponse.toJson).
Value parameters
- body
-
Response body parsed as JSON
- headers
-
Response headers as a multi-valued map (lowercase keys) Build one with JsonHttpResponse.apply and change it with the
with*setters; the constructor andcopyare private, so a new field never breaks callers. - statusCode
-
HTTP status code
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
JsonHttpResponse.type
The HTTP client provider modules and built-in tools use, abstracted so it can be injected and replaced by a test double.
The HTTP client provider modules and built-in tools use, abstracted so it can be injected and replaced by a test double.
Every request method returns a Result and never throws for a transport failure:
- a request that times out is a
Left(org.llm4s.error.TimeoutError); - a connection failure, unknown host or other I/O error is a
Left(org.llm4s.error.NetworkError); - an invalid URL, header or timeout, or an unreadable multipart file, is a
Left(org.llm4s.error.ValidationError); - an interrupted request, or a stream read interrupted mid-body, is a
Left(org.llm4s.error.CancelledError), with the thread's interrupt flag kept.
A non-2xx status is '''not''' an error at this layer: it is a Right response, which the caller inspects (HttpResponse.ensureSuccess, or org.llm4s.llmconnect.provider.HttpErrorMapper.mapHttpError with the response headers).
Headers are passed as single-valued maps. Response headers are multi-valued, keyed in lower case; look one up with header(name).
The trait is deliberately not sealed, so tests can implement it. Methods added to it after 1.0 will have default implementations, so a test double keeps compiling.
Attributes
- Companion
- object
- Supertypes
-
trait AutoCloseableclass Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Llm4sHttpClient.type
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
MultipartPart.type
HTTP response wrapper for streaming (InputStream-based) response bodies.
HTTP response wrapper for streaming (InputStream-based) response bodies.
Use this instead of HttpResponse when the response body must be consumed incrementally (e.g. server-sent events, JSON lines).
Value parameters
- body
-
Response body as an InputStream — caller is responsible for closing it, on error statuses too
- headers
-
Response headers as a multi-valued map (lowercase keys) Build one with StreamingHttpResponse.apply and change it with the
with*setters; the constructor andcopyare private, so a new field never breaks callers. - statusCode
-
HTTP status code
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type