Granular billing

Organize billing for API calls at organization, teamspace and user level.

OpenAI compatible

Your API key decides where the cost of API calls is charged: to you personally, to one of your teamspaces, or to an organization.

Example

from openai import OpenAI

client = OpenAI(
  base_url="https://lightning.ai/api/v1",
  api_key="LIGHTNING_API_KEY",
)

completion = client.chat.completions.create(
  model="openai/gpt-4o",
  messages=[
    {
      "role": "user",
      "content": "What is a fun fact about space?"
    }
  ]
)

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

Supported API keys

Where charges go API key When to use
Organization teamspace An API key scoped to a teamspace in the organization Charge a specific teamspace inside an organization you belong to
Organization account An API key scoped to the organization, with no teamspace Costs are charged to the organization as a whole

Create a scoped API key

In your organization's settings, open API keys and choose Create API Key. Pick a role, and optionally a teamspace. If you don't pick a teamspace, usage is charged to the organization.

Note: The LIGHTNING_API_KEY/ORG_NAME[/TEAMSPACE_NAME] format, where the organization and optional teamspace are appended to the key, is no longer supported and returns a 401. Create a scoped API key instead.

Was this page helpful?

What went wrong?

↑↓ Navigate↵ Open⌘↵ New tabesc Close