Framework integrations

Test TKEN with Vercel AI SDK and LangChain before production

Use TKEN as an OpenAI-compatible model gateway for server-side framework code. Validate the gateway endpoint first, then wire Vercel AI SDK, LangChain JavaScript, or LangChain Python with separate checks for streaming, tools, structured output, and agent loops.

Framework base URL OpenAI-compatible
TKEN_BASE_URL=https://www.tken.shop/v1
TKEN_MODEL=replace-with-a-model-from-/v1/models

1. List models
2. Run one non-streaming chat
3. Wire framework code
4. Test streaming/tools/agents separately
Base URL: https://www.tken.shop/v1
Works where frameworks accept OpenAI-compatible endpoints
Preflight direct API calls before framework rollout

Start outside the framework

A framework error can come from the gateway, model ID, key, request shape, streaming mode, tool-calling assumptions, or app code. Prove the gateway path first so the framework test has a clean baseline.

First check
GET /v1/models
Model source
Use a model ID returned by TKEN
First chat
One small non-streaming request
Key boundary
Server environment only
Feature rollout
Streaming, tools, JSON, agents separately
Evidence
Redacted status, route and failure class

Integration sequence

1. Preflight the endpoint

Confirm that https://www.tken.shop/v1 is reachable, /models returns available model IDs, and a simple chat completion passes with the selected model. Keep prompts and keys out of screenshots and logs.

2. Wire Vercel AI SDK server-side

Use the OpenAI-compatible provider with a server-only API key and baseURL set to the TKEN /v1 endpoint. Start with non-streaming text generation before enabling streaming routes.

3. Wire LangChain JS or Python directly

Configure ChatOpenAI with the TKEN API key, model ID, and custom OpenAI-compatible base URL. Test one direct invoke call before adding chains, retrievers, memory, tools, or agents.

4. Gate optional capabilities

Treat streaming, tool calls, structured output, embeddings, and agent loops as separate capabilities. Route production traffic only after the selected model path has passed the feature you need.

Minimal framework shapes

Keep examples short and server-side during rollout. These shapes show where the OpenAI-compatible base URL belongs; production apps still need timeouts, redaction, fallback, budget controls, and feature checks.

Vercel AI SDK server code
import { generateText } from "ai";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

const tken = createOpenAICompatible({
  name: "tken",
  apiKey: process.env.TKEN_API_KEY,
  baseURL: process.env.TKEN_BASE_URL || "https://www.tken.shop/v1"
});

const { text } = await generateText({
  model: tken(process.env.TKEN_MODEL),
  prompt: "Reply with one short sentence."
});

Framework-specific notes

Vercel AI SDK

Use a server route or backend action for key handling. If a model route does not pass streaming, keep that first rollout on non-streaming generation and test streaming again with a route that passed capability smoke tests.

LangChain JavaScript

Start with a direct ChatOpenAI invoke call and a custom baseURL in configuration. Add tools, agents, callbacks, and tracing only after the direct chat path returns the expected shape.

LangChain Python

Pass base_url to langchain_openai.ChatOpenAI and keep one direct invoke test separate from retrievers, output parsers, chains, and agents. Do not rely on non-standard fields unless tested.

Shared production guardrails

Redact keys, account IDs, private prompts, usage records, and provider dashboard details. Set request timeouts, retry limits, token limits, and rollback criteria before routing user traffic.

Owned examples and guides

Use the public example repo as the implementation reference, then verify the selected model route against your own TKEN key before production traffic.

Failure map

401 or authentication error

Check that the server environment contains the right TKEN key and that the key is not being read from public browser code.

404 or route not found

Confirm that the base URL includes /v1 and that framework code is not appending an incompatible path.

Model not found

Pick a model ID returned by /v1/models instead of copying a model name from another provider dashboard or example.

Feature behaves differently by model route

Test streaming, tool calls, JSON output, embeddings, and agent behavior as separate capability checks before enabling them for production users.

Disclosure: TKEN is an independent third-party OpenAI-compatible API gateway. It is not officially affiliated with Vercel, the AI SDK project, LangChain, OpenAI, or other model providers. Live pricing and available routes may vary by selected model, provider route, account limits, and provider status.

Verify the gateway before framework traffic

Create an API key, list models, run one direct chat request, then wire framework code with explicit capability gates.