Use Jev with Preternatural
Jev
The Preternatural Client SDK does not provide a Jev-specific request method. Use the Client SDK to obtain an authenticated gateway configuration, then pass that configuration to the TypeSafe AI SDK.
Install the SDKs
bun add @preternatural-js/client-sdk @typesafe-ai/sdkConfigure Client SDK client
Use the authenticated customerClient created during the Client SDK setup.
import { ServiceProvider } from '@preternatural-js/client-sdk'
const modelIdentifier = 'jev-latest'
const gateway = await customerClient.createProviderGatewayConfig({
provider: ServiceProvider.typesafeAI,
modelIdentifier,
productId: 'your-product-id'
})Go through Configure Client SDK client for more info.
Configure TypeSafe AI SDK client with Preternatural Gateway headers
The Preternatural gateway URL ends in /v1, while the TypeSafe SDK adds /v1/systemone to its base URL. Remove the existing /v1 segment before creating the TypeSafe client.
import { TypeSafeClient } from '@typesafe-ai/sdk'
const typeSafeBaseURL = gateway.baseURL.replace(/\/v1\/?$/, '')
const jev = new TypeSafeClient({
// TypeSafeClient requires a non-empty API key value.
apiKey: 'PRETERNATURAL_GATEWAY_AUTHENTICATES_REQUESTS',
baseURL: typeSafeBaseURL,
defaultHeaders: gateway.headers,
defaultModel: modelIdentifier,
fetch: gateway.fetchImpl,
retry: { maxRetries: 0 },
})Send a System One request
import { choice } from '@typesafe-ai/sdk'
const result = await jev.systemOne({
state: {
message: 'I was charged twice. Please refund the duplicate charge.'
},
questions: {
category: choice('Which team should handle this request?', {
billing: 'Questions about charges, payments, and refunds',
technical: 'Problems using the product',
other: 'Requests that do not fit another category'
})
}
})
console.log(result.answers.category.choice)