Authentication
هذا المحتوى غير متوفر بلغتك بعد.
GhostMind uses API keys for authenticating Product API requests. API keys are scoped to a workspace and can have restricted permissions.
API Key Format
API keys start with sk-gm- followed by a random string:
sk-gm-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxUsing API Keys
Include your API key in the Authorization header:
Authorization: Bearer sk-gm-...cURL
curl https://ghostmind.optdmsa.com/v1/chat/completions \ -H "Authorization: Bearer sk-gm-..." \ -H "Content-Type: application/json" \ -d '{"model": "auto", "messages": [{"role": "user", "content": "Hello"}]}'Python
import requests
headers = {"Authorization": "Bearer sk-gm-..."}response = requests.post( "https://ghostmind.optdmsa.com/v1/chat/completions", headers=headers, json={"model": "auto", "messages": [{"role": "user", "content": "Hello"}]},)JavaScript
const headers = { Authorization: "Bearer sk-gm-..." };const response = await fetch("https://ghostmind.optdmsa.com/v1/chat/completions", { method: "POST", headers, body: JSON.stringify({ model: "auto", messages: [...] }),});API Key Scopes
API keys can have scopes that restrict what they can access:
| Scope | Description |
|---|---|
chat | Chat completions and streaming |
conversations | Conversation management |
audio | Audio generation and transcription |
Most keys include chat and conversations scopes by default.
Managing API Keys
API keys are managed in the API Keys page of the web app:
- Navigate to API Keys in the sidebar
- Click Create API Key
- Name it and select scopes
- Copy the key immediately — it’s shown only once
- Revoke keys when no longer needed
Authentication Errors
| Status | Error | Cause |
|---|---|---|
| 401 | invalid_api_key | Missing or invalid API key |
| 401 | api_key_revoked | API key has been revoked |
| 403 | insufficient_scope | API key lacks required scope |
| 403 | workspace_disabled | Workspace is disabled |
Next Steps
- Your First Request — Make a chat completion request
- API Keys (User Guide) — Managing keys in the web app
- Errors — Complete error reference