Skip to content
Browse documentation
typescript sdk

Providers and credentials

Choose a provider integration and resolve credentials at the server execution boundary.

Choose the integration that matches the protocol

model-providersExplicit subpaths for OpenAI, Anthropic, Google, Vertex, OpenRouter, Vercel and Z.ai implementations.
model-ai-sdkBridge selected AI SDK language-model behavior into Smoothie inference.
model-typesafeA separate TypeSafe Jev decision API; not an InferenceRuntime provider or generic structured-output helper.

Provider support is not uniform. Check model capabilities and the retained adapter's supported input, streaming and continuation profile before choosing a route. A provider name is not a promise that every upstream API is implemented.

Keep credentials late-bound

Use createInference's resolveCredential callback for server-owned credentials. Bind profiles explicitly when the same provider has multiple accounts, regions or gateway settings. Keep secrets outside contracts, Agent definitions and Tool arguments.

import { createInference } from "@smoothie-framework/runtime/model";
import { createOpenAiResponsesAdapter } from "@smoothie-framework/model-providers/openai";

export function createInferenceForServer(apiKey: string) {
  return createInference({
    providers: [createOpenAiResponsesAdapter()],
    resolveCredential: () => ({ apiKey }),
  });
}

The AI SDK bridge does not erase its own provider limits. TypeSafe owns its native question/decision semantics and does not automatically receive Smoothie inference budgets or routing. Keep those differences visible rather than treating every integration as interchangeable.

Log provider calls without logging content

Requires a Framework release containing @smoothie-framework/diagnostics. Create one channel on the server and pass it to createInference. The same option works with model-providers and model-ai-sdk. This Node/Bun example writes one JSON record per line:

import { createDiagnostics } from "@smoothie-framework/diagnostics";
import { createInference } from "@smoothie-framework/runtime/model";
import { createOpenAiResponsesAdapter } from "@smoothie-framework/model-providers/openai";
import { stdout } from "node:process";

export function createLoggedInference(apiKey: string) {
  const diagnostics = createDiagnostics({
    level: "info",
    capacity: 256,
    maxBytes: 1024 * 1024,
    writeTimeoutMs: 1000,
    sink: {
      write(record, { signal }) {
        if (signal.aborted) return;
        return new Promise<void>((resolve, reject) => {
          stdout.write(JSON.stringify(record) + "\n", (error) => {
            if (error) reject(error);
            else resolve();
          });
        });
      },
    },
  });
  const inference = createInference({
    providers: [createOpenAiResponsesAdapter()],
    resolveCredential: () => ({ apiKey }),
    diagnostics,
  });
  return { inference, diagnostics };
}

Records contain schemaVersion, timestamp, event, level and flat attributes. invocationId groups one generate or stream call; attemptId identifies each provider request, including retries. Error records include a classification, retryability and available HTTP status, provider request ID and retry delay. Prompts, responses, Tool arguments, credentials, raw headers, provider bodies and error stacks are excluded.

TypeSafe accepts the same channel through createTypeSafeClient. It creates its own invocation and attempt IDs and does not retry automatically. Pass runId, traceId and agentId in evaluate's second argument when you need to correlate an evaluation with a run.

import type { DiagnosticEmitter } from "@smoothie-framework/diagnostics";
import { createTypeSafeClient } from "@smoothie-framework/model-typesafe";

export function createLoggedTypeSafe(
  apiKey: string,
  model: string,
  diagnostics: DiagnosticEmitter,
) {
  return createTypeSafeClient({ apiKey, model, diagnostics });
}

Delivery is queued and bounded. Sink failures do not fail inference; overflow or a stalled sink can drop records. Inspect diagnostics.getStats() for dropped records, failures and timeouts. Use asynchronous writes: synchronous work inside a sink still blocks its host. A timed-out write receives an abort signal, and no replacement write starts until it settles.

After stopping new requests and waiting for active calls, await diagnostics.close({timeoutMs: 1500 }) during server shutdown. Inspect the returned stats; completed does not mean every record was delivered. In a serverless handler, attach a bounded diagnostics.flush() to the host's request-lifetime extension, such as waitUntil.

Keep diagnostics in server logs. The channel does not redact custom attributes you emit, so exclude customer content and secrets from your own events and correlation IDs. Buffered records can be lost on process exit; store billing and audit records separately. Omit diagnostics or set level to "off" to disable delivery.