---
title: Authentication
description: Authenticate with Agnic using OAuth2 or API tokens
---

# Authentication

Agnic supports two authentication methods to access the API and AI Gateway.

## Authentication Methods

<Cards>
  <Card title="OAuth2 Integration" href="/docs/authentication/oauth2">
    Let users authorize your app to sign transactions on their behalf
  </Card>
  <Card title="API Tokens" href="/docs/authentication/api-tokens">
    Generate tokens for direct API access in scripts and applications
  </Card>
  <Card title="Available Scopes" href="/docs/authentication/scopes">
    Control what permissions your tokens have
  </Card>
</Cards>

## Which Should I Use?

| Use Case | Recommended Method |
|----------|-------------------|
| Your own scripts/agents | API Tokens |
| CI/CD pipelines | API Tokens |
| Third-party app integration | OAuth2 |
| User-facing applications | OAuth2 |
| MCP servers | API Tokens |
| N8N workflows | OAuth2 |

## Quick Comparison

| Feature | API Tokens | OAuth2 |
|---------|-----------|--------|
| Setup complexity | Simple | Moderate |
| User authorization | Not required | Required |
| Spending limits | Set by you | Set by user |
| Token lifespan | Until revoked | 30-60 days |
| Best for | Personal use | Multi-user apps |

## Token Formats

All Agnic tokens follow a predictable format:

| Prefix | Type | Description |
|--------|------|-------------|
| `agnic_tok_` | API Token | Direct API access token |
| `agnic_at_` | Access Token | OAuth2 access token |
| `agnic_rt_` | Refresh Token | OAuth2 refresh token |

## Next Steps

<Cards>
  <Card title="Create API Token" href="/docs/authentication/api-tokens" />
  <Card title="Implement OAuth2" href="/docs/authentication/oauth2" />
</Cards>
