Skip to main content
Teamspaces isolate resources and data within your organization. By default, API requests are scoped to the teamspace in which the API key was created — its home teamspace.

When you can target a different teamspace

The Datagrid-Teamspace header only takes effect for API keys created with scopeLevel: "account". For these account-scoped keys, the header may select any teamspace under the same account as the key’s home teamspace. For the default scopeLevel: "org" keys, the header is ignored — the request always runs against the home teamspace. To target a different teamspace with an org-scoped key, mint a new key inside the target teamspace.
Key scopeLevelDatagrid-Teamspace behavior
"org" (default)Header is ignored. Request runs against the key’s home teamspace.
"account"Header selects the target teamspace. Must be under the same account as the home teamspace; otherwise the request returns 404.

Option 1: Initialize the client with a teamspace

Initialize the Datagrid client with a teamspace ID — all subsequent requests will use it automatically (account-scoped keys only).
from datagrid_ai import Datagrid

datagrid = Datagrid(
    teamspace="teamspace_id",
)

response = datagrid.converse(
    prompt="Hello world!",
)

print(response.content[0].text)

Option 2: Scope individual requests

Pass the Datagrid-Teamspace header per request — useful when one client addresses multiple teamspaces in the same account.
from datagrid_ai import Datagrid

datagrid = Datagrid()

response = datagrid.converse(
    prompt="Hello world!",
    extra_headers={
        "Datagrid-Teamspace": "teamspace_id",
    },
)

print(response.content[0].text)