Getting a Civitai API Key
An API key is required for authenticated requests: favorites, hidden models, NSFW content, and all SDK operations.
Create an API Key
- Go to Account Settings
- Navigate to API Keys section
- Click Add API key
- Copy the key immediately (shown only once)
Keep your API key secret. Never commit it to source control.
Configuration
Use application settings (recommended):
// builder.Services.AddCivitaiApi(builder.Configuration);
Example appsettings.json:
{
"CivitaiSharp": {
"Api": {
"Key": "your-api-key"
}
}
}
For local development, use User Secrets to store the API key securely.
What Requires Authentication
Core Library:
- Favorites
- Hidden models
- Higher rate limits
- NSFW content (Mature/X levels)
SDK Library:
- All operations (authentication always required)
Next Steps
Quick Start Guide - Get started with CivitaiSharp
Error Handling - Handle API errors gracefully