Skip to content

models: Hugging Face's open models, offered with HF_TOKEN - #12

Merged
vijayakrishnans merged 1 commit into
mainfrom
feat/huggingface-models
Oct 27, 2026
Merged

vijayakrishnans merged 1 commit into
mainfrom
feat/huggingface-models

Conversation

@vijayakrishnans

Copy link
Copy Markdown
Contributor

Adds Hugging Face's Inference Providers as a third model source, beside Workers AI (always on) and the Vercel AI Gateway (with its key).

Models (each served with tool calling by ≥2 providers on router.huggingface.co/v1/models): Kimi K3 (moonshotai/Kimi-K3), GLM 5.3 (zai-org/GLM-5.3), DeepSeek V4.1 Flash (deepseek-ai/DeepSeek-V4.1-Flash), Qwen3.8 27B (Qwen/Qwen3.8-27B).

How:

  • lib/ai/models.ts: huggingFaceModels (via: "huggingface", capabilities known locally), isHuggingFaceConfigured() reads HF_TOKEN per request; getAvailableModels() adds them only with the token.
  • lib/ai/providers.ts: createOpenAICompatible against https://router.huggingface.co/v1, HF_TOKEN as the bearer, built per call. A Hugging Face model with no token falls back to the default Workers AI model, like a gateway model with no key.
  • @ai-sdk/openai-compatible@3.0.5: the same @ai-sdk/provider@4.0.2 / provider-utils@5.0.5 as ai@7.0.15; the lockfile gains only that package.
  • /api/health: models.huggingface connected / not connected.
  • Docs: product README ("Models"), BOOTSTRAP, ai/context/operations.md, .env.example, .dev.vars.example, wrangler comments.

To turn it on in a product: a Hugging Face token with "Make calls to Inference Providers", then wrangler secret put HF_TOKEN --name <reponame>-web-<env>.

Tests: tests/web 51 passed (new: offered only with the token, capabilities without a network call, no-token fallback, a call through the router with the bearer and model id). apps/web typecheck and ultracite clean.

🤖 Generated with Claude Code

Kimi K3, GLM 5.3, DeepSeek V4.1 Flash and Qwen3.8 27B through Hugging
Face's Inference Providers router (OpenAI-compatible chat completions,
@ai-sdk/openai-compatible 3.0.5 — the same provider/provider-utils as
ai 7.0.15). Like the gateway's models they are offered only when their
key is set: HF_TOKEN as a Worker secret, read per request. Each is served
with tool calling by at least two providers on the router. Without the
token a request naming one is answered by the default Workers AI model.

/api/health reports huggingface connected / not connected; the product
README, BOOTSTRAP and operations context say how to turn it on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T12:02:32.234270Z 831f111 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@vijayakrishnans
vijayakrishnans merged commit b31aea6 into main Oct 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant