Skip to Content
AI

Getting started with AI on Zenifra

This guide shows how to generate your credential, limit usage with a budget, and make the first call using an OpenAI-compatible client.

Prerequisites

  • a Zenifra account
  • access to the Zenifra console
  • available credit, including promotional credits when granted
  • a Python project with the openai package installed
  • an environment variable to store the key

Step 1: Create the API key

Create New API Key dialog with name, allowed models and quotas highlighted

In the Zenifra console, open AI models, click Create API Key, and enter a name that identifies the environment, application, or team that will use the key. The name accepts 4 to 24 characters and may contain only unaccented letters, numbers, and hyphens, with no spaces, such as production-api-01.

Required permissions

For AI operations through a user session, an owner has full access; assistant and member need the organization grants. For automation, organization API Keys use the AI key ID:

ActionMinimum scope
Create an AI keyai_key.create on organization:*
Read a keyai_key.read on ai_key:<key-id>
Change the budgetai_key.update on ai_key:<key-id>
Remove/deactivate a keyai_key.delete on ai_key:<key-id>
Read usage and costsai_usage.read on ai_key:<key-id>; use * only for all permitted keys

The scopes above are independent: creating a key must not be treated as authorization to read usage for other keys. The key used by the client for ai.zenifra.com is an inference credential separate from the organization API Key.

Keys belong to the organization but retain their creator link. Removing a member from the organization automatically deactivates the AI keys created by that member.

This key will be used by your application to authenticate calls to the https://ai.zenifra.com/v1 endpoint. The secret is shown only once after creation; copy it and store it securely like any other production secret.

Step 2: Define budget and allowed models

When creating the key, you select the Allowed Models and set the Daily quota (BRL) and Monthly quota (BRL). You can also adjust the Key RPM and Key TPM, which can be lower than the organization limits but never higher. Quotas never increase the organization's available credit.

This flow is useful to separate usage by environment, team, or integration.

Allowed models accept all-team-models (every model available to the organization, the default) or 1 to 50 unique catalog IDs, such as zenifra/qwen3.8-flash. IDs outside the catalog are rejected.

Manage keys through the API

The same console operations are available at https://api.zenifra.com/v1, with the x-organization-id header and the scopes from the previous section.

MethodEndpointDescription
GET/ai/modelsCatalog of models that can be enabled for a key
POST/ai/keysCreates a key; the secret (api_key) appears only in the 201 response
GET/ai/keysLists the organization's keys, always paginated
GET/ai/keys/:idReads a key
PATCH/ai/keys/:id/budgetChanges the key's daily and monthly quotas
DELETE/ai/keys/:idRevokes the key
GET/ai/rate-limitsReads the organization's RPM and TPM limits (requires ai_key.create)

The list accepts page (starting at 1, default 1), limit (1 to 50, default 50), and user_email to filter the keys of an active member; a member can only filter by their own email. The response includes a pagination field:

{
  "status": "success",
  "data": [
    {
      "id": "6650f1c2a9b8c7d6e5f40312",
      "name": "production-api-01",
      "models": ["zenifra/qwen3.8-flash"],
      "quota_limits": { "daily": 10, "monthly": 200 },
      "rpm": 60,
      "tpm": 100000,
      "is_active": true,
      "status": "active",
      "created_at": "2026-10-01T12:00:00.000Z",
      "expires_at": null
    }
  ],
  "pagination": { "page": 1, "limit": 50, "total": 1, "pages": 1 }
}

A revoked key, or one past its expiration, appears with status: "inactive". A revoked key never becomes active again.

When changing quotas, send quota_limits with positive daily and monthly values; monthly must be greater than or equal to daily.

Key limits and errors

Each organization can have up to 100 active AI keys at the same time. Revoked or expired keys do not count.

StatusCode or messageWhen it happensHow to act
400One or more models are not availablean ID in models is not in the cataloguse IDs from GET /v1/ai/models or all-team-models
400AI key rate limits must be within the organization limitsrpm or tpm above the organization limitcheck GET /v1/ai/rate-limits
400validation messageinvalid key id, name outside the pattern, or invalid quotasfix the request
404API key not foundthe key does not exist or does not belong to the organizationcheck the id
409AI_KEY_LIMIT_REACHEDthe organization already has 100 active keysrevoke keys you no longer use before creating another
409AI_KEY_REVOKEDattempt to change the quota of a revoked keycreate a new key
503AI models are temporarily unavailablethe catalog is temporarily unavailabletry again shortly

Step 3: Make the first request

Install the OpenAI SDK in your Python project:

pip install openai

Then use the example below. For this documentation, we will use the zenifra/qwen3.8-flash model, if it is enabled for your key in the console:

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://ai.zenifra.com/v1",
    api_key=os.environ["ZENIFRA_AI_API_KEY"],
)

response = client.chat.completions.create(
    model="zenifra/qwen3.8-flash",
    messages=[
        {
            "role": "user",
            "content": "What is the average temperature in southern Brazil?",
        }
    ],
)

print(response.choices[0].message.content)

Step 4: Track usage and costs

Usage panel on the AI models page with total spend, requests, tokens and success rate, filterable by period and member

In the console, you can view:

  • daily costs
  • total costs
  • usage by model
  • current models
  • created keys

How billing works

AI usage can be billed by tokens, images, or another unit identified by the catalog. Token-based models can have a standard (peak) price, an off-peak price, and context tiers selected by the input-token count. Review AI model pricing and the Console before shipping integrations to production.

AI usage is prepaid and uses the organization's shared credit. When no usable credit remains, new calls are blocked. A saved card does not enable additional AI usage.

FAQ

Do I need to use the OpenAI SDK?

Not necessarily. The important part is to use a client compatible with the OpenAI API and configure base_url and api_key correctly.

Where can I track current models and prices?

In the console, on the AI Models page, Available Models tab. The public list is also available at GET https://ai.zenifra.com/v1/models.

Can I limit the use of a key?

Yes. When creating the key, you set daily and monthly quotas in BRL, the RPM and TPM limits, and which models it can access. Quotas can be changed later in Edit quota.

How many AI keys can I create?

Up to 100 active keys per organization. Revoke keys you no longer use to free up room.

Next steps

Last updated on

On this page