Spavik
GuidesGet started

Authentication

Connect your application or agent with a Spavik API key.

Create an API key in your Spavik workspace and store it in your application's secret manager. Use that key for the REST API, Python SDK, TypeScript SDK or MCP.

Connect with your API key

Your integration uses an API key, which starts with sk-spv-api-. Workspace admin keys, which start with sk-spv-admin-, manage the workspace and cannot train or predict. Set SPAVIK_API_KEY as shown in Get started. Both SDKs read it and send X-Spavik-Api-Key to https://api.spavik.co. The examples below list the models accessible to that key.

from spavik import Spavik

spavik = Spavik()
for model in spavik.models():
    print(model.id)

Without a key, both SDKs refuse the call before sending it, except for listing engines and engine families:

SpavikAuthError: no API key: set SPAVIK_API_KEY or pass api_key. Nothing was sent.

The JavaScript message says pass apiKey. An explicitly empty key disables the environment fallback, for example Spavik(api_key="") in Python or new Spavik({ apiKey: '' }) in JavaScript: the client then does not read SPAVIK_API_KEY and refuses the call the same way. The API checks permissions and quotas for the operation you request.

For the MCP server, configure the same X-Spavik-Api-Key header in your client.

Keep keys out of your code

Store the secret when it is created: it is shown only once. Do not commit it, include it in browser code or print it in logs. Load it from an environment variable or secret manager at runtime.

When replacing a key, update your deployed callers and verify access before retiring the previous key. Manage keys and account settings in your workspace; your integration only needs the key used for its API calls.

When a call is refused

Status and codeMeaning
401 TOKEN_INVALID or 401 AUTH_REQUIREDno key reached the API: check the X-Spavik-Api-Key header. The API currently answers TOKEN_INVALID in this case; AUTH_REQUIRED is the intended code. Handle both the same way
401 API_KEY_INVALIDthe key is unknown, malformed or revoked
401 API_KEY_EXPIREDthe key has passed its expiry date: create a new one
403 ADMIN_KEY_CANNOT_PREDICTan admin key was used for training or predictions

A permission refusal is different from insufficient credits or a model quota: use the returned error code to decide what to change. See Error codes.

How is this guide?

Last updated on

On this page