Skip to main content

Projects

Think of your organisation as a school, and each project as a classroom. Every classroom has its own rules, its own piggy bank and its own keys, so one classroom cannot spend another's money.

A project is a separate workspace inside your organisation. Use projects to give different teams or products their own:

One organisation holds several projects, each with its own policy, budget, environments and API keys

Policy
The regions that may be used and the max tokens per request. Checked on every request.
Budgets
A monthly spending limit, with an optional hard limit that stops requests. Alert thresholds are saved, but alerts are not sent yet.
Environments
Dev, staging and production inside one project.
API keys
Keys that work for this project only.

When should I use projects?​

SituationWhat to do
Several products share one NuRoute accountOne project per product
Different teams with different region rulesOne project per team
You want dev, staging and production kept apartUse environments inside one project
You want to keep costs apartOne project per workload, each with its own budget

Project-scoped API keys​

A key made for a project can only reach that project's things. So you can hand a team an API key without giving them access to your other projects.

Requests made with the key belong to its project, so the project's policy and budget apply. You do not need an extra header. If a request names a different project with the X-NuRoute-Project-ID header, it is refused with 403. So is a header that names a project outside your organization. Project IDs are matched without regard to upper or lower case.

What a project-scoped key can use:

EndpointWith a project-scoped key
POST /v1/chat/completionsRequests run under the key's project
GET /v1/models, GET /v1/artemis-optionsAs for any key
GET /projectsLists only the key's project
GET /projects/{id} and /v1/projects/{id}/...The key's project only. Its settings, usage, budget and environments can be read. Changing them is refused with 403, because it needs an owner's or admin's session
GET /v1/usage/...The key's project's usage. Leave out project_id or pass the key's project
GET /v1/requests, GET /v1/routing/historyOnly the key's project's requests
GET /v1/requests/{id}, its replay, GET /v1/routing/history/{id}Only a request of the key's project

Everything else is refused with 403 forbidden: your organization's routing configuration, billing, members, API keys, provider keys, the audit log and organization settings.

An organization-wide key can read the routing configuration, usage and requests. But changing any setting, and managing API keys and members, needs an owner's or admin's session (the dashboard, or in the SDKs a token from auth.login()). No API key has a role, so even an organization-wide key gets 403 there.

403 or 404: what is the difference?​

  • 403 means the endpoint (or, for a project's settings, the change) is closed to project-scoped keys.
  • 404 means the key is allowed to use the endpoint, but you asked about something outside its project. NuRoute answers exactly as if it did not exist. This covers another project's settings, a project_id of another project (or none) on the usage endpoints, and a request made under another project or under no project.

Good to know​

  • A project-scoped key can only be created for an active project of your organization. Any other project_id is refused with 400.
  • When its project is deleted, the key stops working. Requests made with it are refused with 401, just like a revoked key.

Environments​

An environment lets you run dev and production work in the same project, without making separate projects. Each environment has its own short name (a slug), such as dev, staging or prod, and can be marked as production.

Policy enforcement​

A project's policy is its set of rules. Read or change it with GET / PUT /v1/projects/{id}/policy.

The policy applies to every request of the project: those made with its project-scoped API key, and those that name it with the X-NuRoute-Project-ID header.

A project policy can only make your organization's policy stricter, never looser. Even your organization's fallbackBehavior cannot relax it: if the organization's rules leave no provider, a relaxing fallback still picks only among what the project allows.

FieldEffect when set
allowed_regionsOnly providers that serve one of these regions, written like the organization's allowed regions (EU, US, APAC, Global, or an exact region such as eu-west-1; not case-sensitive; how regions match). A provider that declares no region is left out unless you allow Global. It applies on top of the organization's regions
max_tokensThe most output tokens a request may ask for. A larger max_tokens is refused with 400 invalid_request_error. A request that sets no max_tokens is sent to the provider with this limit, or with the model's own output limit if that is smaller. 0 sets no limit

An empty list, and max_tokens: 0, set no rule.

A PUT replaces the whole policy

Any field you leave out is cleared. So read the policy first, then send it back with your change.

With auto or an Artemis option, only providers in the allowed regions are used, whichever router decides. When none of them can serve the request, the gateway answers 422 no_available_model, for example with the message this project's policy leaves no provider that can serve this request.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{ "error": { "type": "invalid_request_error", "message": "max_tokens 8000 exceeds this project's limit of 4096" } }

Budget enforcement​

A project's budget is its spending limit for the calendar month. Read or change it with GET / PUT /v1/projects/{id}/budget. It has three fields: monthly_usd, alert_pct and hard_limit.

  • The month is the calendar month in UTC.
  • alert_pct defaults to 80 when a PUT leaves it out.
  • current_spend is the project's spend since the first of the month (UTC). It is the same figure the hard limit reads.

What counts as spend? What the project's requests cost you:

  • An Artemis request (auto or an Artemis option) costs Artemis's price per token.
  • Any other request costs the provider's price.
  • A request on your own provider key counts at the provider's price too, even though the provider bills you for it directly.
  • A request that is still running counts at its estimate, then at its real token count once it finishes.
  • A failed request counts nothing.

What does the hard limit do? With hard_limit: true and a monthly_usd above 0, once the month's spend reaches monthly_usd:

  • New requests of the project are refused with 402 Payment Required, type budget_exceeded.
  • Requests that are already running finish.
  • Requests are accepted again once you raise the budget, or on the first of the next month (UTC).

Without hard_limit, nothing is refused.

A PUT replaces the whole budget

A field you leave out is reset (a missing hard_limit turns the hard limit off). So send all three fields.

HTTP/1.1 402 Payment Required
Content-Type: application/json

{ "error": { "type": "budget_exceeded", "message": "this project has spent its monthly budget of $500.00 ($500.12 this month, UTC); requests are refused until the budget is raised or the month ends" } }

Things to know:

  • The check can lag by 30 seconds. NuRoute re-reads a project's spend at most every 30 seconds, and a request's cost is known only once it finishes. A busy project can go past its budget by that much traffic. The budget itself is read on every request, so a raised budget applies from the next request.
  • It fails closed. If the spend cannot be read, requests of a project with a hard limit are refused with 503 (routing_error) until it can be read again. Projects without a hard limit are not affected.
  • It is not your credit balance. 402 insufficient_credits means your organization's prepaid credits are used up. 402 budget_exceeded means this project's own budget is spent.
  • Alerts are not sent yet. alert_pct is saved and returned, but nothing reads it. No email, webhook or event fires when spend crosses it or reaches the budget.

How projects relate to the organization's settings​

A project's settings apply to its requests: those made with a project-scoped API key, or that name the project with the X-NuRoute-Project-ID header. Requests made with an organization-level key use the organization's settings, unless they name a project.

A project narrows the organization's rules and never loosens them. Its allowed regions apply on top of the organization's, and the organization's fallbackBehavior never relaxes them. The budget and max tokens belong to the project alone. Routing controls lists where each setting lives.