InferenceClient

class baseten.client.InferenceClient(*, api_key, headers=None, model_id=None, chain_id=None, environment=None, base_url_override=None, http_client_override=None, close_http_client_on_close=None)

Bases: object

Synchronous client for the Baseten Inference API.

Can be used as a context manager to ensure the underlying HTTP client is closed on exit.

Parameters:
  • api_key (str)

  • headers (Mapping[str, str] | None)

  • model_id (str | None)

  • chain_id (str | None)

  • environment (str | None)

  • base_url_override (str | None)

  • http_client_override (httpx.Client | None)

  • close_http_client_on_close (bool | None)

property api: ApiClient

The generated API client.

The generated API surface is not covered by stability guarantees and may change between versions.

close()

Close the client, optionally closing the underlying HTTP client.

Return type:

None

classmethod default_base_url(*, model_id=None, chain_id=None, environment=None)

Compute the default inference base URL.

Parameters:
  • model_id (str | None) – Model ID. Mutually exclusive with chain_id.

  • chain_id (str | None) – Chain ID. Mutually exclusive with model_id.

  • environment (str | None) – Optional environment name.

Returns:

The computed base URL.

Raises:

ValueError – If both or neither of model_id and chain_id are provided.

Return type:

str

property http_client: Client

The underlying HTTP client.

property options: InferenceClientOptions

Client options.