Menu
Important
Stay updated on React2Shell

LlamaIndex

Last updated September 24, 2025

LlamaIndex makes it simple to build knowledge assistants using LLMs connected to your enterprise data. This guide demonstrates how to integrate Vercel AI Gateway with LlamaIndex to access various AI models and providers.

  1. First, create a new directory for your project and initialize it:

  2. Install the required LlamaIndex packages along with the package:

  3. Create a file with your Vercel AI Gateway API key:

    If you're using the AI Gateway from within a Vercel deployment, you can also use the environment variable which will be automatically provided.

  4. Create a new file called with the following code:

    The following code:

    • Initializes a LLM instance with your API key
    • Configures the model to use Anthropic's Claude 4 Sonnet via the AI Gateway
    • Creates a chat message and streams the response
  5. Run your application using Python:

    You should see a streaming response from the AI model.


Was this helpful?

supported.