convez.ai
MCP ServerIntegração & APIsIntermediário
vivian254338489

TKEN OpenAI-Compatible Gateway Examples

vivian254338489/tken-openai-compatible-examples

Gateway OpenAI-compatível com exemplos de SDK, testes e guias de integração

Ver no GitHub
InicialPluginScore · de 0 a 100

MCP server com exemplos, testes de endpoint e guias de migração para usar o gateway TKEN (gateway OpenAI-compatível independente) com múltiplas famílias de modelos. Inclui configurações para SDKs populares, documentação de smoke tests e checklists de produção.

Instalação

$npx convez-ai vivian254338489/tken-openai-compatible-examples

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
57%
Último commit
há 5 meses
Versão
v0.25.0
Issues abertas
3
Contribuidores
1

Casos de uso

  • Migrar aplicações existentes para gateway OpenAI-compatível
  • Testar múltiplos provedores de modelos via única base URL
  • Validar compatibilidade de integração com LangChain, LlamaIndex, Vercel AI
  • Preflight de endpoints antes de produção
  • Configurar agentes e workflows com MCP

Veredito

Recurso bem estruturado para equipes que precisam abstrair múltiplos provedores de LLM atrás de uma interface OpenAI-compatível. Documentação abrangente com smoke tests, checklists e guias de troubleshooting, mas requer experiência com SDKs e APIs para máximo proveito.

README

A tradução para o português deste README ainda está na fila.

TKEN OpenAI-Compatible Gateway Examples

TKEN is an independent OpenAI-compatible API gateway for developers who want to test multiple model families from one base URL:

https://www.tken.shop/v1

This repository shows how to point common SDKs and developer tools at the TKEN endpoint without storing API keys in source control.

Disclosure: TKEN is an independent third-party API gateway. It is not officially affiliated with OpenAI, Anthropic, DeepSeek, MiniMax, Alibaba, Google, xAI, or other model providers. Model availability, pricing, context limits, streaming behavior, tool support, and rate limits can vary by account, channel, and provider status.

Quick Links

Local Guides

NeedGuide
Evaluate an OpenAI-compatible gateway before adoptiondocs/api-gateway-evaluation.md
Move an existing SDK app to a custom base URLdocs/sdk-migration-guide.md
Smoke-test SDK streaming, JSON mode, and tool callsdocs/openai-sdk-capability-smoke.md
Use Vercel AI SDK with an OpenAI-compatible providerdocs/vercel-ai-sdk-openai-compatible.md
Use LangChain with an OpenAI-compatible chat modeldocs/langchain-openai-compatible.md
Use LlamaIndex with an OpenAI-compatible LLM routedocs/llamaindex-openai-compatible.md
Import Postman or Bruno endpoint smoke testsdocs/api-client-collections.md
Capture redacted smoke-test evidencedocs/smoke-evidence-runner.md
Run endpoint preflight and interpret tester outputdocs/endpoint-preflight-playbook.md
Check endpoint behavior before launchdocs/compatibility-checklist.md
Debug 401, 404, model, quota, timeout, and CORS errorsdocs/troubleshooting.md
Select model routes using current pricing and /v1/modelsdocs/pricing-model-selection.md
Add route-level model selection and spend controlsdocs/cost-guardrails.md
Prepare production rollout, alerts, spend limits, and rollbackdocs/production-readiness-checklist.md
Connect Open WebUI directly to TKENdocs/openwebui-direct-tken.md
Preflight TKEN for agent and MCP-capable workflowsdocs/agent-mcp-gateway-preflight.md
Review MCP host config boundaries for TKENdocs/mcp-host-gateway-config.md
Run Open WebUI through LiteLLM to TKENdocs/openwebui-litellm-tken-stack.md
Start Open WebUI and LiteLLM with Docker Composedocs/openwebui-litellm-docker-compose.md
Issue LiteLLM virtual keys with budgets and rate limitsdocs/litellm-virtual-keys-spend-control.md
Wire Continue and Cursor-style coding tools to TKENdocs/continue-cursor-coding-tools.md
Choose between Cursor, Continue, Open WebUI, and LiteLLMdocs/cursor-continue-openwebui-litellm-comparison.md
Add a manual GitHub Actions endpoint smoke testdocs/ci-endpoint-smoke-tests.md
Configure Open WebUI, LiteLLM, Cursor, Continue, and agentsdocs/tool-integration-guide.md
Record a short demo or launch asset without exposing secretsdocs/demo-script.md
Share this repo transparently in communitiesdocs/community-disclosure.md

Environment

Set your key locally. Do not commit real API keys.

export TKEN_API_KEY="sk-your-tken-key"
export TKEN_BASE_URL="https://www.tken.shop/v1"
export TKEN_MODEL="replace-with-an-available-model"

PowerShell:

$env:TKEN_API_KEY="sk-your-tken-key"
$env:TKEN_BASE_URL="https://www.tken.shop/v1"
$env:TKEN_MODEL="replace-with-an-available-model"

Examples

ExampleFile
curl chat completionexamples/curl-chat.sh
curl quickstart with /models checkexamples/curl-quickstart.sh
Node.js no-dependency chat completionexamples/node-chat.mjs
Node.js OpenAI SDK chat completionexamples/node-openai-sdk.mjs
Node.js OpenAI SDK streaming, JSON, and tool smoke testsexamples/node-openai-sdk-capability-smoke.mjs
Vercel AI SDK with @ai-sdk/openai-compatibleexamples/vercel-ai-sdk-openai-compatible.mjs
LangChain JS with @langchain/openaiexamples/langchain-js-openai-compatible.mjs
Python no-dependency chat completionexamples/python-chat.py
Python OpenAI SDK chat completionexamples/python-openai-sdk.py
Python OpenAI SDK streaming, JSON, and tool smoke testsexamples/python-openai-sdk-capability-smoke.py
LangChain Python with langchain-openaiexamples/langchain-python-openai-compatible.py
LlamaIndex Python with llama-index-llms-openai-likeexamples/llamaindex-openai-compatible.py
Node.js /models and chat smoke testexamples/smoke-test.mjs
Cost-aware route-level model selectionexamples/model-router.mjs
Reusable OpenAI-compatible endpoint testertools/endpoint-tester.mjs
Redacted smoke evidence runnertools/smoke-evidence.mjs
Manual GitHub Actions endpoint smoke test.github/workflows/tken-endpoint-smoke.yml
Browser/Web UI configexamples/web-ui-config.js

API Client Collections

Use these when you want a no-code endpoint check before wiring an SDK, UI, proxy, or agent:

ClientFile
Postmancollections/postman/tken-openai-compatible-smoke.postman_collection.json, collections/postman/tken-local.postman_environment.json
Brunocollections/bruno/tken-openai-compatible-smoke/

Run GET /models first, then choose a returned model ID before running POST /chat/completions. See docs/api-client-collections.md for import flow, variables, and safe evidence guidance.

Smoke Evidence Runner

When you need a paste-ready issue, rollout, or handoff artifact, run the evidence CLI:

node tools/smoke-evidence.mjs \
  --base-url "$TKEN_BASE_URL" \
  --api-key-env TKEN_API_KEY \
  --model "$TKEN_MODEL" \
  --out smoke-evidence.md

It records status, latency, model discovery, selected model, failure class, and shape-level chat evidence without storing API keys, prompt text, or full response text.

For output fields, JSON mode, and redaction rules, see docs/smoke-evidence-runner.md.

Tool Configs

ToolFile
Open WebUI direct to TKENconfigs/openwebui-direct-tken.env.example
Open WebUI minimal templateconfigs/openwebui.env.example
LiteLLMconfigs/litellm-config.yaml
Open WebUI + LiteLLM + TKENconfigs/openwebui-litellm.env.example, configs/litellm-openwebui-tken.yaml
Docker Compose Open WebUI + LiteLLM + TKENdocker-compose.openwebui-litellm-tken.yml, configs/openwebui-litellm-docker-compose.env.example, configs/litellm-openwebui-tken.compose.yaml
LiteLLM virtual keys and spend controlsconfigs/litellm-virtual-keys-tken.yaml
Continue and Cursor coding toolsconfigs/continue-tken.config.yaml, configs/cursor-continue-config.md
Production readiness templateconfigs/production-readiness.template.json
Codex-style configconfigs/codex.tken.json
OpenClaw-style configconfigs/openclaw.tken.json
Agent gateway preflight profileconfigs/agent-gateway-preflight.json
MCP host gateway review profileconfigs/mcp-host-gateway-review.json

For setup notes across these tools, see docs/tool-integration-guide.md. If you are choosing between Cursor, Continue, Open WebUI, and LiteLLM, start with docs/cursor-continue-openwebui-litellm-comparison.md. For direct Open WebUI setup, see docs/openwebui-direct-tken.md. For Open WebUI behind LiteLLM, see docs/openwebui-litellm-tken-stack.md; for a runnable local container stack, use docs/openwebui-litellm-docker-compose.md. For LiteLLM virtual keys, see docs/litellm-virtual-keys-spend-control.md. For coding tools, see docs/continue-cursor-coding-tools.md. For agent and MCP-capable host preflight, see docs/agent-mcp-gateway-preflight.md. For MCP host config review, see docs/mcp-host-gateway-config.md.

For framework integrations, start with docs/vercel-ai-sdk-openai-compatible.md for Vercel AI SDK apps, docs/langchain-openai-compatible.md for LangChain chains or agents, and docs/llamaindex-openai-compatible.md for LlamaIndex query engines or agents. If you prefer API-client imports before code, start with docs/api-client-collections.md. Validate /v1/models and one non-streaming chat request before enabling streaming, tools, structured output, embeddings, query engines, or agent loops.

For CI checks, see docs/ci-endpoint-smoke-tests.md. The included GitHub Actions workflow is manual only, uses the TKEN_API_KEY repository secret, and defaults to /models reachability before optional chat completion testing.

Smoke Test Without SDKs

curl "$TKEN_BASE_URL/models" \
  -H "Authorization: Bearer $TKEN_API_KEY"
curl "$TKEN_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $TKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$TKEN_MODEL"'",
    "messages": [{"role": "user", "content": "Reply with one short sentence."}]
  }'

Endpoint Tester CLI

Use the reusable tester when you want a structured compatibility check before wiring an endpoint into an app:

node tools/endpoint-tester.mjs \
  --base-url "$TKEN_BASE_URL" \
  --api-key-env TKEN_API_KEY \
  --model "$TKEN_MODEL"

It checks:

  • GET /models
  • model ID discovery
  • optional non-streaming POST /chat/completions
  • timeout handling
  • JSON output for CI or diagnostics

The tester reads API keys from environment variables only. It does not store keys or print keys.

For a step-by-step preflight sequence, failure mapping, and safe issue-report evidence template, see docs/endpoint-preflight-playbook.md.

Node.js OpenAI SDK

Install:

npm install openai

Run:

node examples/node-openai-sdk.mjs

Python OpenAI SDK

Install:

python -m pip install openai

Run:

python examples/python-openai-sdk.py

Framework Integrations

Vercel AI SDK:

npm install ai @ai-sdk/openai-compatible
npm run node:vercel-ai-sdk

LangChain JS:

npm install @langchain/openai
npm run node:langchain

LangChain Python:

python -m pip install -U langchain-openai
python examples/langchain-python-openai-compatible.py

LlamaIndex Python:

python -m pip install -U llama-index llama-index-llms-openai-like
python examples/llamaindex-openai-compatible.py

SDK Capability Smoke Tests

After /models and non-streaming chat pass, verify optional SDK features one at a time:

node examples/node-openai-sdk-capability-smoke.mjs stream
node examples/node-openai-sdk-capability-smoke.mjs json
node examples/node-openai-sdk-capability-smoke.mjs tools

Python:

python examples/python-openai-sdk-capability-smoke.py stream
python examples/python-openai-sdk-capability-smoke.py json
python examples/python-openai-sdk-capability-smoke.py tools

See docs/openai-sdk-capability-smoke.md before enabling streaming, JSON parsers, or tool-call dependent agents in production.

Model Routing Pattern

Use local route names in your application:

free-model    -> summaries, extraction, drafts, batch work
premium-gpt   -> coding, hard reasoning, final answers

Validate /v1/models before choosing a production model ID.

Example:

node examples/model-router.mjs fast "Summarize this request in one sentence."

Set TKEN_MODEL_FAST, TKEN_MODEL_BALANCED, or TKEN_MODEL_REASONING when you want route-specific model IDs.

Safety Notes

  • Keep API keys server-side. Do not put TKEN keys in public browser JavaScript.
  • Prefer environment-variable key injection over command-line key arguments.
  • Validate /v1/models before choosing a model ID.
  • Test non-streaming before streaming.
  • Add retries and timeouts before sending production traffic.
  • Add budget and usage limits before connecting automated agents.
  • Keep CI endpoint checks manual until key limits, ownership, and alerting are clear.
  • Keep a documented rollback route map before moving user-facing traffic.
  • Do not expose real keys, account identifiers, usage records, or private prompts in demos, issue reports, screenshots, or community posts.
Ver o original no GitHub

Bom para

Relacionados