Get gateway configuration
client.gateway.providerConfiguration() gives another library what it needs to send requests through the Modem gateway: the base URL, the customer’s authentication headers, and the Client SDK’s fetch. It establishes the customer’s session first if needed. productId and provider are required, and modelIdentifier is optional.
Create an authenticated configuration
import { ServiceProvider } from '@preternatural-js/client-sdk'
const gateway = await client.gateway.providerConfiguration({
provider: ServiceProvider.openai,
modelIdentifier: 'gpt-4o-mini',
productId: 'your-product-id'
})The result has this shape:
type ProviderGatewayConfiguration = {
baseURL: string
headers: Record<string, string>
fetchImpl: FetchLike
}FetchLike, the type of a fetch function, is exported by the SDK.
The baseURL depends on the provider. For OpenAI, it ends in /v1, and the OpenAI SDK appends /chat/completions. For Anthropic, it has no final /v1, and the Anthropic SDK appends /v1/messages. Pass baseURL to either SDK unchanged.
Get the public gateway configuration
client.gateway.configuration() returns the base URL, the transport’s default headers, and the fetch implementation, without customer headers. Use it for the gateway’s public routes.
Check that the gateway is reachable
The gateway’s root URL needs no authentication:
curl https://gateway.preternatural.ai/{"ok":true,"service":"gateway"}