Skip to main content
Teamspaces allow you to isolate resources and data within your organization. By default, all requests are scoped to the teamspace in which the API key was created. To scope requests to a different teamspace, you can use one of two methods.

Option 1: Initialize the Client with a Teamspace

You can initialize the Datagrid client with a teamspace ID. All subsequent requests from that client will automatically be scoped to that teamspace.
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

Alternatively, you can scope individual requests by passing the Datagrid-Teamspace header. This is useful when you need to make requests to different teamspaces from the same client.
from datagrid_ai import Datagrid

datagrid = Datagrid()

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

print(response.content[0].text)