Skip to Content

Built-in test provider

The Preternatural AI provider serves lorem-ipsum through local gateway handlers. It is useful for application loading states, streaming controls and protocol integration without a real upstream provider key. It does not generate a meaningful model answer or validate a production provider’s feature compatibility.

Configure a test product

  1. Add a Preternatural AI account with the public test value preternatural-lorem-ipsum-api-key.
  2. Connect that account to a Sandbox project/product.
  3. Add a usage rule for model lorem-ipsum, using the request or token measure appropriate to the API being tested.
  4. Authenticate a Sandbox customer, including a synthetic customer if desired.

That key is a published test constant, not a personal credential. It cannot authenticate an unrelated provider. A wrong test value is refused with 401 and another model ID with 400. Modem authentication, product rules, request history and usage accounting still apply.

Sandbox mode alone does not replace other providers with this test provider. Select ExternalServiceProvider.preternaturalAI explicitly.

Exercise streaming

import { ExternalServiceProvider } from '@preternatural-js/client-sdk' const text = await client.chat.stream({ scope: { provider: ExternalServiceProvider.preternaturalAI, modelIdentifier: 'lorem-ipsum', productId: 'your-test-product-id' }, messages: [{ role: 'user', content: 'Show a streaming answer.' }], maxTokens: 64 }, chunk => appendText(chunk))

The provider caps generated output at 256 words. It supports local response shapes for Chat Completions, Completions, Responses, Messages, embeddings, image generation/editing, transcription and translation. It does not implement speech synthesis or System One. It is deliberately unpriced; a zero reference cost here is not an estimate for a real model.

Control timing and variability

For lower-level requests, the JSON body can include lorem_ipsum:

{ "model": "lorem-ipsum", "messages": [{ "role": "user", "content": "Test the loading state." }], "stream": true, "lorem_ipsum": { "streaming": { "instant": false, "timeToFirstTokenMs": 300, "tokensPerSecond": 12, "tokensPerChunk": 2, "randomSeed": 17 }, "variability": { "enabled": false, "randomSeed": 23 } } }

Send this with an authenticated gateway configuration; the basic chat helper does not expose the custom lorem_ipsum field. instant: true skips artificial delays. Timing jitter, chunk jitter and seeded phrase/punctuation variability are also available in the provider configuration. Invalid option values fall back to defaults instead of making the request fail.

Test both instant and delayed delivery, interruption and cancellation. A passing local test establishes your app’s handling of these test responses; separately test the real provider integration before shipping it.

Last updated on