Connect your AI · API key

Grok (xAI API)

Grok, with our tools.

  1. 1

    Install the SDK and set your xAI key.

    bash
    pip install openai
    export XAI_API_KEY=xai-…
  2. 2

    Run this. Replace YOUR_API_KEY with your key from the API keys page.

    python
    import os
    from openai import OpenAI
    
    client = OpenAI(api_key=os.environ["XAI_API_KEY"], base_url="https://api.x.ai/v1")
    resp = client.responses.create(
        model="grok-4.7",
        tools=[{
            "type": "mcp",
            "server_url": "https://people-api.arihaan.ai/mcp",
            "server_label": "arihaan-people",
            "authorization": "Bearer YOUR_API_KEY",
        }],
        input="Use Arihaan People to find VPs of Sales at software companies in Texas. Count them first, then show the first 10 with title, company and city.",
    )
    print(resp.output_text)
Try this prompt

“Use Arihaan People to find VPs of Sales at software companies in Texas. Count them first, then show the first 10 with title, company and city.”