Grok ↗ is s a general purpose model that can be used for a variety of tasks, including generating and understanding text, code, and function calling.
Endpoint
URL structure
When making requests to Grok ↗, replace https://api.x.ai/v1 in the URL you are currently using with https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/grok.
Examples
cURL
Use OpenAI SDK with JavaScript
If you are using the OpenAI SDK with JavaScript, you can set your endpoint like this:
Use OpenAI SDK with Python
If you are using the OpenAI SDK with Python, you can set your endpoint like this:
Use Anthropic SDK with JavaScript
If you are using the Anthropic SDK with JavaScript, you can set your endpoint like this:
Use Anthropic SDK with Python
If you are using the Anthropic SDK with Python, you can set your endpoint like this:
Was this helpful?
What did you like?
What went wrong?
Thank you for helping improve Cloudflare's documentation!