Skip to main content

xAI (Grok)

Use xAI’s Grok models for general tasks, reasoning, and real-time web search. xAI exposes an OpenAI-compatible API, making integration seamless.

Setup


Factory

string
required
Model ID (e.g., "grok-3", "grok-3-mini", "grok-2-vision", "grok-2").
XAIConfig
Optional { apiKey?, baseURL? }.

Supported Models


Basic Example


Tool Calling


Vision


Full Example


Environment Variables


Cross-References

  • OpenAI — Similar API format
  • DeepSeek — Another reasoning-focused model
  • Tools — Tool calling guide