Add xAI (Grok) provider for @workglow/ai#622
Merged
Merged
Conversation
Add @workglow/xai, a cloud provider for the xAI Grok API. xAI exposes an OpenAI-compatible REST surface, so the provider reuses the `openai` SDK pointed at https://api.x.ai/v1 and mirrors the @workglow/openai structure. Capabilities served: - text.generation (chat + prompt, vision input via message content) - text.generation + tool-use - text.generation + json-mode (structured output) - text.rewriter, text.summary - image.generation (grok-2-image; non-streaming) - model.count-tokens (tiktoken cl100k_base approximation) - model.info, model.search (curated Grok fallback list) Wiring: - providers/xai package (node + browser builds, ./ai and ./ai-runtime) - re-export from the workglow meta-package (./xai, ./xai/runtime) - register in @workglow/test and examples/cli - widen validateProviderBaseUrl vendor union to include "xai" - unit + runtime-metadata tests, plus a skipped conformance integration test Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jx794dFEj3P7jT6pgytkaq
Match "image" only as a full id segment (grok-2-image-1212) instead of any substring, so a chat/vision model whose id merely contains "image" (e.g. a hypothetical "reimagine-*") is not misrouted to image-only capabilities and stripped of text.generation/tool-use/json-mode. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jx794dFEj3P7jT6pgytkaq
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
sroussey
added a commit
that referenced
this pull request
Jul 10, 2026
## @workglow/ai ### Features #### providers - add xAI (Grok) AI provider(#622) ## workglow ### Features - add node-llama-cpp provider to workglow meta-package (#629) - add OpenRouter provider for @workglow/ai (#626) #### providers - add xAI (Grok) AI provider(#622) ## @workglow/storage ### Bug Fixes #### storage - genuine CAS for updateWhere on IndexedDb + HttpTabularProxy (#628) ## @workglow/test ### Features - add OpenRouter provider for @workglow/ai (#626) #### providers - add xAI (Grok) AI provider(#622) ### Bug Fixes #### storage - genuine CAS for updateWhere on IndexedDb + HttpTabularProxy (#628) ## @workglow/indexeddb ### Bug Fixes #### storage - genuine CAS for updateWhere on IndexedDb + HttpTabularProxy (#628) ## @workglow/xai ### Features #### providers - add xAI (Grok) AI provider(#622) ## @workglow/openrouter ### Features - add OpenRouter provider for @workglow/ai (#626) ## @workglow/cli ### Features #### providers - add xAI (Grok) AI provider(#622)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
@workglow/xaiprovider package that integrates xAI's Grok models with the Workglow AI framework. xAI exposes an OpenAI-compatible REST API, so this provider reuses theopenaiSDK pointed athttps://api.x.ai/v1.Key Changes
New provider package (
providers/xai/) with full AI task support:Capability inference (
Xai_Capabilities.ts):Client abstraction (
Xai_Client.ts):Streaming run-functions for all capabilities:
TextGenerationTaskandAiChatTaskBrowser and Node.js variants:
js-tiktokenin browser, WASMtiktokenin Node.jsai.ts,ai.browser.ts, andai-runtime.tsIntegration tests (
Xai_Generic.integration.test.ts):XAI_API_KEYenvironment variable is setPackage exports and registration:
registerXai()for worker-backed moderegisterXaiInline()for inline moderegisterXaiWorker()for worker server registration@workglow/workglowmeta-packageImplementation Details
ImageValuevia data URIhttps://claude.ai/code/session_01Jx794dFEj3P7jT6pgytkaq