Skip to main content

API keys

Obtaining an API key

API key is connected to your account and is used to authenticate your requests to the xChat API. You can obtain your API key by following the steps below:

  1. Visit xChat app and log in to your account and navigate to the Settings page.

    settings-icon.png

  2. Click on the API Keys tab.

    api-keys-section.png

  3. Create new API keys from here or manage existing ones.

Using an API key

To use an API key, you need to include it in the x-api-key header of your requests. The header should look like this:

x-api-key: YOUR_API_KEY

Here is an example of how you can use an API key with the curl command:

curl -X GET "https://api.xchat.stochastic.ai/auth/v1/users/me" -H "x-api-key: YOUR_API_KEY"

Note: Do not share your API key with anyone. Keep it secure and do not expose it in public repositories or client-side code.