API Documentation

OpenAI-compatible. Drop-in replacement.

Logfare is 100% OpenAI API compatible. Point any OpenAI-compatible client at https://logfare.ai/v1 and it just works. No SDK changes needed.

Authentication

Model requests require your API key or an approved app credential. Get a key by registering for a free account. Model discovery is public.

Your regular API key provides inference and authenticated model listing. App integrations support finer permissions and optional read-only account information approved by the user.

Send your key in the Authorization header as a Bearer token:

Header
Authorization: Bearer YOUR_API_KEY

Base URL

All API endpoints are under https://logfare.ai/v1

MethodEndpointDescription
POST/v1/chat/completionsChat completions (streaming supported)
POST/v1/completionsLegacy text completions
POST/v1/messagesAnthropic-style messages API
POST/v1/responsesOpenAI Responses API
POST/v1/images/generationsImage generation
POST/v1/images/editsImage editing
POST/v1/audio/speechText-to-speech
POST/v1/audio/transcriptionsSpeech-to-text
POST/v1/embeddingsText embeddings
GET/v1/modelsList available models
GET/v1/statusSystem + model health status

Chat Completions

POST /v1/chat/completions

Standard OpenAI chat completions format. Streaming via SSE is supported — set "stream": true.

ParameterTypeRequiredDescription
modelstringYesModel ID (see /models)
messagesarrayYesArray of {role, content} message objects
streambooleanNoStream response via SSE (default: false)
temperaturenumberNoSampling temperature (default: 1.0)
max_tokensintegerNoMax tokens to generate
top_pnumberNoNucleus sampling (default: 1.0)
stopstring/arrayNoStop sequence(s)
curl
curl https://logfare.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "kimi-k2.5",
  "messages": [
    {"role": "user", "content": "Hello!"}
  ]
}'
Python
from openai import OpenAI

client = OpenAI(
    base_url="https://logfare.ai/v1",
    api_key="YOUR_API_KEY",
)

response = client.chat.completions.create(
    model="kimi-k2.5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
Python (streaming)
from openai import OpenAI

client = OpenAI(
    base_url="https://logfare.ai/v1",
    api_key="YOUR_API_KEY",
)

stream = client.chat.completions.create(
    model="kimi-k2.5",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Auto Routing

Use logfare/auto (aliases: auto, logfare/random) as the model name and Logfare routes to the best available model automatically — falling through a quality-ordered chain on failures so you always get a response.

The chain is ordered by model quality (best first). If a provider fails, the next model is tried. Your key's permissions are respected: mappings derived from models you can't access (private or premium models requiring opt-in) are filtered out before routing.

curl
curl https://logfare.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "logfare/auto",
  "messages": [
    {"role": "user", "content": "Hello!"}
  ]
}'

The three names are interchangeable — logfare/auto, auto, and logfare/random all route to the same chain. See /models for the current list of models in the chain and their health status.

Anthropic Messages API

POST /v1/messages

Anthropic-compatible messages endpoint. Use the same request format as the Anthropic API — model, messages, max_tokens, system, etc. The x-api-key header or Authorization: Bearer both work.

curl
curl https://logfare.ai/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
  "model": "claude-sonnet-4",
  "max_tokens": 1024,
  "messages": [
    {"role": "user", "content": "Hello!"}
  ]
}'

Image Generation

POST /v1/images/generations

ParameterTypeRequiredDescription
modelstringYesImage model ID (e.g. flux-2-pro)
promptstringYesText description of the image
nintegerNoNumber of images (default: 1)
sizestringNoImage dimensions as WxH (e.g. 1024x768). Parsed and sent as width/height to the provider.
stepsintegerNoNumber of diffusion steps (model-dependent). Higher = more detail, slower. Mapped to num_steps for providers that require it.
response_formatstringNob64_json or url (default: b64_json)
curl
curl https://logfare.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "flux-2-pro",
  "prompt": "a cat sitting on a windowsill, warm afternoon light",
  "size": "1024x1024",
  "n": 1
}'

Request limits

These are the currently configured request budgets. Changes made by staff are reflected here automatically.

ScopeRequest budgetConcurrent requests
Regular account 20 requests per minute
500 requests per hour
2,500 requests per day
3
New account 5 requests per minute
100 requests per hour
250 requests per day
1
Shared network / IP 60 requests per minute
3,000 requests per hour
25,000 requests per day
Account and service limits apply

The new-account budget applies during the first 24 hours after account creation, unless staff has approved an access exception.

The service also allows up to 64 requests in progress across all accounts. Model and provider budgets can impose additional shared limits; the limits above do not guarantee available model capacity.

Account and network request budgets apply across endpoints. Multiple windows (minute, hour, day, or custom intervals) and concurrent-request limits may apply. New accounts can have lower initial quotas. Windows use fixed UTC boundaries; provider daily budgets reset at 00:00 UTC. Retrying or regenerating a key does not reset an account's allowance.

Staff may assign an individual account a custom request budget or concurrency allowance. These replace the corresponding account defaults, while network, service, model, and provider limits still apply.

A 429 response explains the limit. Respect Retry-After when present and use backoff. A 403 may require completing Discord screening, waiting for account/member eligibility, or contacting staff.

Embeddings

POST /v1/embeddings

ParameterTypeRequiredDescription
modelstringYesEmbedding model ID
inputstring/arrayYesText or array of texts to embed

Text to Speech

POST /v1/audio/speech

ParameterTypeRequiredDescription
modelstringYesTTS model ID
inputstringYesText to synthesize
voicestringNoVoice name (model-dependent)

Audio Transcriptions

POST /v1/audio/transcriptions

Send an audio file as multipart/form-data. Returns transcribed text.

List Models

GET /v1/models

Returns all active public models. No authentication required.

curl
curl https://logfare.ai/v1/models

Errors

Errors follow the OpenAI API error format:

Error response
{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": null
  }
}
StatusTypeMeaning
401authentication_errorMissing or invalid API key
403permission_errorModel not available for your key
404not_found_errorModel not found
429rate_limit_errorAccount, network, concurrency, or provider request limit reached
500server_errorUpstream provider error — try again or try another model
503server_errorService temporarily unavailable

Account API

Account APIs are available while the linked Discord account is in the Logfare server. New accounts verify on the registration page; existing accounts can log in and link Discord at /migrate. Leaving suspends access until rejoining. A Discord account can be linked to one Logfare account.

MethodEndpointDescription
POST/v1/auth/registerCreate account, get API key
GET/v1/auth/discord/startStart registration verification in a browser
GET/v1/auth/discord/link/startLink Discord to a logged-in existing account
POST/v1/auth/discord/membership/checkRefresh membership after rejoining the Logfare server
POST/v1/auth/loginLogin; unlinked accounts must migrate first
GET/v1/auth/meGet current user info
POST/v1/auth/regenerate-keyGenerate new API key
POST/v1/auth/consentSet eval-dataset consent
DELETE/v1/me/deleteDelete account

Registration requests must include the short-lived, HttpOnly verification cookie issued by the Discord flow. Use the web registration page to complete verification before calling this endpoint.

Register
curl -X POST https://logfare.ai/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
  "username": "myuser",
  "password": "mypassword",
  "tos_accepted": true,
  "age_confirmed": true
}'

App integrations

Users can grant an app specific access without sharing their password, browser session, or main API key. They can revoke its separate credential at any time.

Register your application

In Developer Apps, create an app and choose its permissions. Its public lfa_… app ID identifies the registration. Each account can have five apps; deleting one frees a slot.

Who can connect? Choose Anyone or Only you. Only you restricts approval to the creator's Logfare account. Switching to it revokes other users' connections; switching back permits new approvals without restoring revoked tokens.

App authentication defaults to App ID only, for distributed apps and plugins. Anyone knowing the ID can start a request, but account access still requires user approval. For backends or private automation, choose Require app secret: requests must also authenticate with the generated secret. Copy it when shown; Logfare stores only its hash. Keep it out of distributed apps, where it could be extracted.

Changing authentication or resetting a secret cancels unfinished connection attempts. Existing approved connections stay active. An app ID alone does not prove which executable is running; confirm that you started the connection in an app you trust.

Select permissions

Each connection can request a subset of the permissions you register. Users see and approve those exact permissions. Scopes are read-only for account data; none can change privacy choices, API keys, or account settings.

Chat and codinginference:chat

Send text-model requests and receive responses, including streaming and tool calls.

Imagesinference:images

Generate and edit images using your account's available models.

Audioinference:audio

Generate speech and transcribe audio using your account's available models.

Videoinference:video

Generate videos using your account's available models.

Embeddingsinference:embeddings

Create embeddings using your account's available models.

Read account usageusage:read

View aggregate account-wide usage: totals, time charts, and breakdowns by model and API/app connection. No prompts, responses, or individual request history.

Read privacy preferencesconsent:read

View training and evaluation preferences, including when each was last changed. Cannot change either preference.

Read basic account infoaccount:read

View your Logfare user ID, username, and account creation date. No API key or account changes.

Read Discord account and server statusdiscord:read

View your linked Discord user ID, whether you are in the Logfare server, and when you joined. This status remains readable after leaving the server while your Logfare account is active. No Discord token, role list, or Discord account access.

inference:chat covers chat, completions, Anthropic Messages, and Responses. Images covers generation and edits; audio covers speech and transcription. Scopes do not bypass account access, training requirements, or shared limits. /v1/models is public.

Connect an account

Secret-required apps authenticate both requests below using HTTP Basic auth: the app ID as username and app secret as password. Form-encoded client_secret with client_id is also supported; use one authentication method. Never put a secret in a URL. App ID only clients omit the secret.

  1. Request a device code with your app ID and registered scopes.
  2. Show the user code and open verification_uri_complete; also offer the manual verification_uri. The user signs in, verifies Discord if prompted, then approves or denies.
  3. Poll at the returned interval using the temporary device_code.
  4. Store the access token in the host's secure credential manager and send it as a Bearer token.
Start a connection
POST https://logfare.ai/v1/integrations/oauth/device_authorization
Content-Type: application/x-www-form-urlencoded

client_id=lfa_YOUR_APP_ID&scope=inference%3Achat%20consent%3Aread

This requests chat and read-only privacy preferences; register both first. If omitted, scope defaults to registered inference:chat. Unknown or unregistered scopes return invalid_scope.

The response includes device_code, user_code, verification_uri, verification_uri_complete, expires_in=900 (15 minutes), and interval=5 (seconds).

Check approval
POST https://logfare.ai/v1/integrations/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=lfa_YOUR_APP_ID&device_code=DEVICE_CODE

Success returns a Bearer access token, granted scopes, and a 180-day expiry. Device codes are single-use; there is no refresh token, so reconnect after expiry or revocation.

Waiting, errors, and recovery

  • authorization_pending: keep polling; slow_down: add at least five seconds to the interval.
  • For HTTP 429, honor Retry-After. Back off on network errors or HTTP 503, and let the user cancel.
  • access_denied: stop. For expired_token or invalid_grant, offer a new connection.
  • invalid_client: check the app ID, status, and required secret. For invalid_scope, check registered permissions. On API 401, clear the stale token; on insufficient_scope, request new approval.

Read approved account information

GET endpointRequired scopeResponse
/v1/me/usage?hours=168usage:readAccount-wide totals, zero-filled time buckets, model and API/app breakdowns, last API use, and generation time. Windows: 24, 168 (default), or 720 hours. Cached for 60 seconds after checking access.
/v1/me/consentconsent:readtraining_opt_in, eval_dataset_opt_out, and their respective training_pref_updated_at and eval_pref_updated_at timestamps (null if never changed).
/v1/me/profileaccount:readuser_id, username, and UTC created_at.
/v1/me/discorddiscord:readdiscord_user_id as a string or null, discord_is_member, and discord_joined_at (null if unlinked or unavailable). No Discord access token or role list.
Read privacy preferences
GET https://logfare.ai/v1/me/consent
Authorization: Bearer <access_token>

{"training_opt_in": false, "eval_dataset_opt_out": false}

For model selection, hide models marked requires_training_optin=true when training_opt_in=false. Evaluation preference is independent and does not unlock models. Logfare still checks current access on every inference request.

The account owner's browser session also works, but a Bearer token needs its own scope. These read-only endpoints are not a Sign in with Logfare service: browser callbacks and identity tokens are not provided. Deactivation revokes connections. Leaving the Logfare Discord server blocks inference and account reads until access is restored; discord:read can still report membership for an active account.

Permissions and connection lifecycle

Changing an app's permissions never silently expands existing credentials. Removing a scope removes it from credentials and invalidates pending requests that need it. Users can revoke connections individually; disabling or deleting an app revokes all of them. Revoked credentials stay revoked, while usage attribution is retained.

Developers see connection totals, not users' credentials, prompts, responses, or request history. Account data requires a user's approved token with the matching scope.

Connect and make a test request

Run your integration's normal setup or connect command, approve the requested permissions in Logfare, then select a Logfare model in the integration. For an OpenAI-compatible client, use this configuration:

Logfare connection settings
Base URL: https://logfare.ai/v1
API credential: the access token returned after approval
Model: logfare/auto

Keep /v1 exactly once in the base URL. Test with a short chat request, then review the connection and usage in your dashboard. Revoke test connections you no longer need.

Use HTTPS outside loopback development. Never log device codes or access tokens or put them in URLs. The protocol follows the OAuth device authorization grant.