← All workflows

Workflow

AI SDK & LangChain integration preflight

Check an OpenAI-compatible endpoint, fix NaN streamed usage, compare AI Gateway with direct keys and test agent tool calls.

Sources checked:

What you can do

Prepare a versioned integration test for compatible endpoints, missing stream usage, gateway billing, and agent tool calls.

An OpenAI-compatible endpoint does not establish support for every API feature. Pin the SDK, provider package, endpoint and exact model together before comparing results. The historical NaN fix belongs to AI SDK 4.

Build your execution checklist

Inputs are processed in this browser only and cleared when you close or refresh the page.

You have a base URL and model ID, but your application fails after changing providers.

Fill in the template

Template preview compatible.md

Integration manifest
SDK version: {{SDK version}}
Provider package/version: {{Provider package}}
Base URL (no key): {{Base URL}}
Exact model ID: {{Model ID}}
Required features: {{Required features}}

Acceptance matrix
- Plain text: pending
- Stream final event: pending
- Usage: unknown until supplied
- Tool call and tool result round trip: pending
- Structured output: pending
- Deliberate invalid request: pending

Read the full steps

Connect an OpenAI-compatible endpoint

You have a base URL and model ID, but your application fails after changing providers.

  1. Record the installed ai and provider package versions from your lockfile.
  2. Use the dedicated compatible provider package documented for your SDK version; keep the key on the server.
  3. Test plain text, stream termination, one tool call and your actual schema separately.
  4. Save response status, request ID and sanitized body for each test; mark unsupported features explicitly.
Template preview: compatible.md
Integration manifest
SDK version: {{SDK version}}
Provider package/version: {{Provider package}}
Base URL (no key): {{Base URL}}
Exact model ID: {{Model ID}}
Required features: {{Required features}}

Acceptance matrix
- Plain text: pending
- Stream final event: pending
- Usage: unknown until supplied
- Tool call and tool result round trip: pending
- Structured output: pending
- Deliberate invalid request: pending

Diagnose missing or NaN stream usage

The answer streams correctly but token accounting is absent or NaN.

  1. Separate transport completion from reported usage: text alone does not prove usage was sent.
  2. Record your SDK major version before applying a historical workaround.
  3. In AI SDK 4, createOpenAI needs compatibility: 'strict' to stream token counts (the default openai instance already sets it). With createOpenAICompatible, set includeUsage: true. Check your installed version's API before copying either option.
  4. Preserve missing usage as null and compare a captured final event with a non-streaming request before estimating costs.
Template preview: usage.md
Usage incident
SDK/provider versions: {{Versions}}
Endpoint: {{Endpoint}}
Terminal event observed: {{Terminal event}}
Raw sanitized usage object: {{Usage object}}
input_tokens: null
output_tokens: null
Reason unknown: {{Missing evidence}}
Never replace absent usage with zero in billing or evaluation.

Choose gateway or direct-provider credentials

A model string works in one deployment but authenticates or bills differently in another.

  1. In AI SDK 5 and later, a plain creator/model string goes through AI Gateway, the default global provider, unless the code sets globalThis.AI_SDK_DEFAULT_PROVIDER or calls an imported provider such as openai(...). Record which route each call takes.
  2. Gateway auth depends on the environment: Vercel deployments use OIDC automatically, local runs need AI_GATEWAY_API_KEY or a token from vercel env pull, and an API key, when present, is always used instead of OIDC even if it is invalid. Keep gateway and direct-provider keys in separate server variables.
  3. Run the same small task on each route and record the billed account, latency and failures. For a gateway call, pass providerMetadata.gateway.generationId to getGenerationInfo() to see its provider, cost and token usage; with BYOK, the gateway uses your own provider credentials.
  4. Choose the route from your own results on this task rather than from unmeasured reliability rankings.
Template preview: gateway.md
Route comparison
Task and acceptance rule: {{Task}}
Route A provider + base URL + billing account label: {{Route A}}
Route B provider + base URL + billing account label: {{Route B}}
Exact model IDs: {{Models}}
Data routing requirements: {{Requirements}}
Completed result: pending
Total billed cost including retries: unknown
p50 / p95 latency: unknown
Decision and evidence link: pending

Select a Deep Agents model

Your agent needs filesystem operations, planning and tool calls, not just text completion.

  1. Use a LangChain chat model with tool-calling support.
  2. Check the provider:model identifier in the installed integration and provider catalog.
  3. Test a sandboxed read, write, tool error and recovery on fixtures before giving production access.
  4. Record the harness and tool environment alongside model results; published basic evaluations do not establish success on your long task.
Template preview: deep-agents.md
Agent acceptance fixture
Provider:model: {{Provider and model}}
Harness/integration versions: {{Versions}}
Allowed test directory: {{Sandbox directory}}
Task: create report.txt from two fixture files; verify source numbers; recover from one unavailable tool.
Success: correct report, no writes outside sandbox, tool failure visible.
Run IDs and result hashes: pending
Production tool permission review: pending

Scope & limits

  • No network calls or keys are used here. Endpoint compatibility and cost still require your own runtime evidence.
  • Templates are checklists, not drop-in code for every SDK version.

Questions & answers

Does compatible mean every feature works?
No. Record support separately for each endpoint, model and feature you need.

Verified sources

Templates are authored by Kunavo. External product behavior depends on the linked sources and your account settings.