Skip to content

Add xAI Responses API provider with web search#16

Merged
writeameer merged 1 commit into
mainfrom
feature/xai-responses-api
Apr 7, 2026
Merged

Add xAI Responses API provider with web search#16
writeameer merged 1 commit into
mainfrom
feature/xai-responses-api

Conversation

@writeameer
Copy link
Copy Markdown
Contributor

Summary

  • New provider/xai/ package implementing forge.Provider via the xAI Responses API
  • Built-in server-side tools: xai.WithWebSearch() and xai.WithXSearch() with domain/handle filtering
  • Native function calling with flat tool definitions (xAI format, not OpenAI-nested)
  • Citation extraction from inline url_citation annotations — accessible via provider.LastCitations()
  • 7 httptest-based tests covering: basic generate, function calls, tool results, web search + citations, API errors
  • Updated hello-world example with xai-search provider option
  • Updated README and design docs

Test plan

  • go vet ./... — clean
  • go test ./... — all 45 tests pass (38 existing + 7 new)
  • Live tested with grok-4-1-fast-non-reasoning + web search — returns rich results with 13+ citations
  • Both examples build cleanly

🤖 Generated with Claude Code

New provider/xai package implementing forge.Provider via the modern
xAI Responses API. Supports built-in server-side tools (web search,
X search) with domain/handle filtering, native function calling with
flat tool definitions, and citation extraction from inline annotations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@writeameer writeameer merged commit 5508f0a into main Apr 7, 2026
1 check 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