تخطَّ إلى المحتوى

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-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Using API Keys

Include your API key in the Authorization header:

Terminal window
Authorization: Bearer sk-gm-...

cURL

Terminal window
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:

ScopeDescription
chatChat completions and streaming
conversationsConversation management
audioAudio 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:

  1. Navigate to API Keys in the sidebar
  2. Click Create API Key
  3. Name it and select scopes
  4. Copy the key immediately — it’s shown only once
  5. Revoke keys when no longer needed

Authentication Errors

StatusErrorCause
401invalid_api_keyMissing or invalid API key
401api_key_revokedAPI key has been revoked
403insufficient_scopeAPI key lacks required scope
403workspace_disabledWorkspace is disabled

Next Steps