> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

To ensure secure access to Prisma AIRS AI Gateway's APIs, authentication is required for all requests. This guide provides the necessary steps to authenticate your requests using the AI Gateway API key, regardless of whether you are using the SDKs for Python and JavaScript, the OpenAI SDK, or making REST API calls directly.

## Obtaining Your API Key

[Create](https://stratacloudmanager.paloaltonetworks.com/) or [log in](https://stratacloudmanager.paloaltonetworks.com/) to your Strata Cloud Manager account. Grab your account's API key from the "Settings" page.

Based on your access level, you might see the relevant permissions on the API key modal - tick the ones you'd like, name your API key, and save it.

<Card title="JWT-based Authentication" href="#jwt-based-authentication">
  You can also authenticate the AI Gateway using JWT Tokens. Learn more here
</Card>

## Using Your API Key

### REST API

<Tabs>
  <Tab title="cURL">
    ```sh theme={"system"}
    curl https://aigw.portkey.ai/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $PORTKEY_API_KEY" \
      -d '{
        "model": "@openai-prod/gpt-4o",
        "messages": [
          { "role": "system", "content": "You are a helpful assistant." },
          { "role": "user", "content": "Hello!" }
        ]
      }'
    ```
  </Tab>
</Tabs>

### OpenAI SDK

When integrating the AI Gateway through the OpenAI SDK, modify the base URL and add the `Authorization` header for authentication. Here's an example of how to do it:

<Info>
  Gateway headers go in the SDK's `defaultHeaders` / `default_headers` parameter. Most requests
  need only `x-portkey-provider`, and even that is unnecessary when you prefix the model with the
  provider slug — `"model": "@openai-prod/gpt-4o"`.
</Info>

<Tabs>
  <Tab title="NodeJS">
    ```js theme={"system"}
    import OpenAI from 'openai';

    const openai = new OpenAI({
      apiKey: "PORTKEY_API_KEY",
      baseURL: "https://aigw.portkey.ai/v1",
    });

    async function main() {
      const chatCompletion = await openai.chat.completions.create({
        messages: [{ role: 'user', content: 'Say this is a test' }],
        model: '@openai/gpt-4o',
      });

      console.log(chatCompletion.choices);
    }

    main();
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"system"}
    from openai import OpenAI

    openai_client = OpenAI(
        api_key="PORTKEY_API_KEY",
        base_url="https://aigw.portkey.ai/v1",
    )
    response = openai_client.chat.completions.create(
            messages=[{'role': 'user', 'content': 'Say this is a test'}],
            model='@openai/gpt-4o'
    )
    ```
  </Tab>
</Tabs>

Read more [here](/docs/aigw/integrations/llms/openai).

## JWT-based Authentication

The AI Gateway supports JWT-based authentication as a secure alternative to API Key authentication. With JWT authentication, clients can authenticate API requests using a JWT token that is validated against a configured JWKS (JSON Web Key Set).

This enterprise-grade authentication method is available as an add-on to any AI Gateway plan. JWT authentication provides enhanced security through:

* Temporary, expiring tokens
* Fine-grained permission scopes
* User identity tracking
* Centralized authentication management

<Card title="JWT Token Authentication" href="/docs/aigw/product/enterprise-offering/org-management/jwt">
  Learn how to implement JWT-based authentication with the AI Gateway
</Card>

<Note>
  <b>Interested in adding JWT authentication to your AI Gateway plan?</b>

  [Contact our sales team](https://portkey.sh/jwt) to discuss pricing and implementation details.
</Note>


## Related topics

- [Authentication](/docs/aigw/product/mcp-gateway/authentication.md)
- [JWT Authentication](/docs/aigw/product/enterprise-offering/org-management/jwt.md)
- [Cursor](/docs/aigw/integrations/mcp-clients/cursor.md)
- [MCP Registry](/docs/aigw/product/mcp-gateway/mcp-registry.md)
