Skip to content

docs: use Langchain::LLM::OpenAI with OpenAI-compatible APIs such as xAI Grok - #1093

Open
andreibondarev wants to merge 2 commits into
mainfrom
docs-openai-compatible-xai
Open

andreibondarev wants to merge 2 commits into
mainfrom
docs-openai-compatible-xai

Conversation

@andreibondarev

Copy link
Copy Markdown
Collaborator

Fixes #1029.

What

#1029 asks for Grok support. xAI's API is OpenAI-compatible (/v1/chat/completions, with tool calling), and Langchain::LLM::OpenAI already passes llm_options to OpenAI::Client, whose uri_base points it at another host. So Grok works today without a new class, but the README didn't say so.

Change

README: a short "OpenAI-compatible APIs (xAI Grok, ...)" section under LLM initialization, showing llm_options: { uri_base: "https://api.x.ai/" } with a Grok chat_model, and noting that such an llm works with Langchain::Assistant. ruby-openai 8.1 joins uri_base with v1/ and the path, so this resolves to https://api.x.ai/v1/chat/completions. CHANGELOG [DOCS] entry.

No code change. A dedicated Langchain::LLM::XAI class could come later if Grok needs its own defaults; the open OpenRouter (#916) and Astraflow (#1036) PRs take that route for their providers.

Tests

Docs only. I checked the URL building in ruby-openai's OpenAI::HTTP#uri; nothing was run against the xAI API.

This change was made with Claude Code (Anthropic).

andreibondarev and others added 2 commits October 21, 2026 18:30
…xAI Grok

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Grok is not support

1 participant