Skip to content
Log inGet startedHugging FaceGitHub

Get started

API keys

Every request to the models needs an API key. This page covers where to keep it, how to check it, and how usage is counted.

Create an account, make a key on the API keys page, and request credits on the Credits page. A key looks like yh-..., belongs to a project of your organization, and spends the organization’s credits.

  • Organization: your company, lab or team. It holds the members, the credits and the projects. You can belong to several.
  • Project: one use of the models, such as a pipeline, a product or a client. Each project has its own keys and its own usage and logs. Every organization starts with a Default project, and owners and admins can create more on the Projects page.
  • Key: belongs to one project. A member’s own key is handed to the project if they leave. A project key (made by an owner or admin) is for production and keeps working when people come and go.

Credits are shared by the whole organization. To stop one project from spending them all, give it a monthly or total cap; each key can also have its own cap. Archiving a project revokes its keys and keeps its usage.

Set the key as an environment variable. The Python library, the command line and agent skills all read it from there:

Terminal window
export YHAT_API_KEY="<your-key>"
  • Python: Client() reads YHAT_API_KEY. You can also pass Client(api_key="..."), or keep the key in a .env file loaded with python-dotenv.
  • HTTP: send it as Authorization: Bearer <key>.
  • Never commit a key, paste it into a shared notebook, or log it. The library never writes it to disk or to its logs.

This confirms the key works and shows which models it can use and how much of its quota is left:

from yhatlabs import Client
yh = Client() # reads YHAT_API_KEY from the environment
me = yh.whoami()
print(me["models"])
print(me["usage"]["left"])
Output
['chakra-ts', 'chakra-tab']
{'monthly': None, 'total': 1000}

Parameters: Client.whoami

models lists the models the key may call. usage.left is what remains of its quota per period: None in Python (null in the CLI’s JSON) means no cap for that period.

Tags add up spend by experiment, pipeline or client. Give a key tags on its edit page (for example prod or client-acme); they go on every call it makes. A call can add its own with a header:

Terminal window
curl https://api.yhatlabs.com/v1/series/forecast \
-H "Authorization: Bearer $YHAT_API_KEY" \
-H "X-Yhat-Tags: experiment-12,weekly" \
-H "Content-Type: application/json" -d @request.json

Up to 10 tags per key and 10 per call: lowercase letters, digits and . _ : -, at most 40 characters each. Usage shows spend by tag, and the logs filter by it.

Calls spend credits from your organization. Each call is counted in tokens, from the work it causes (a forecast by its history and horizon, a table call by its rows and columns), and paid in credits at your organization’s rate (1 credit per 1M tokens by default). Amounts are shown with decimals: a small call costs about 0.02 credits, and every reply states its cost in usage.credits. Limits has the rules, and POST /v1/estimate (or yh.estimate_table()) the cost of a call before you make it. Your balance, what refills it and the last 30 days of use are on the Credits page.

When the organization has no credits left, calls fail with HTTP 402 and error type no_credits; owners request more on the Credits page. When a key’s or a project’s cap is reached, calls fail with HTTP 429 and error type quota_exceeded. A call that fails on our side does not count.

Keys we issued directly (for example for a benchmark) carry their own quota instead: forecasts counted in series, tables in credits, each with an optional monthly and total cap. When one is used up, calls fail with HTTP 429 and error type quota_exceeded (RateLimitError in Python), which is not retried.

To send requests to a dedicated or self-hosted deployment instead of the hosted API, set its address:

Terminal window
export YHAT_BASE_URL="https://your-deployment.example.com"

In Python, Client(base_url=...) does the same for one client.