Skip to content

API Client

The Scope3AI SDK provides both synchronous (Client) and asynchronous (AsyncClient) HTTP clients for interacting with the Scope3AI API.

All the commands from the AsyncClient can be invoked with the await.

scope3ai.api.client

Classes:

  • Client

    Synchronous Client to the Scope3AI HTTP API

  • AsyncClient

    Asynchronous Client to the Scope3AI HTTP API

  • ClientBase

    Base client class for communicating with the Scope3AI HTTP API.

  • ClientCommands

    Base class that implements the command methods for interacting with the Scope3AI API.

Client

Client(api_key: Optional[str] = None, api_url: Optional[str] = None)

Bases: ClientBase, ClientCommands

Synchronous Client to the Scope3AI HTTP API

Methods:

create_client

create_client() -> Client

execute_request

execute_request(url: str, method='GET', params: Optional[dict] = None, json: Optional[dict] = None, response_model: Optional[BaseModel] = None, with_response: Optional[bool] = True)

AsyncClient

AsyncClient(api_key: Optional[str] = None, api_url: Optional[str] = None)

Bases: ClientBase, ClientCommands

Asynchronous Client to the Scope3AI HTTP API

Methods:

create_client

create_client()

execute_request async

execute_request(url: str, method='GET', params: Optional[dict] = None, json: Optional[dict] = None, response_model: Optional[BaseModel] = None, with_response: Optional[bool] = True)

ClientBase

ClientBase(api_key: Optional[str] = None, api_url: Optional[str] = None)

Base client class for communicating with the Scope3AI HTTP API.

Handles authentication and provides core request functionality for both synchronous and asynchronous clients.

Attributes:

  • api_key (Optional[str]) –

    API key for authentication, can be passed in or read from env var

  • api_url (Optional[str]) –

    URL for the API, defaults to production endpoint

Methods:

api_key instance-attribute

api_key = api_key or getenv('SCOPE3AI_API_KEY')

api_url instance-attribute

api_url = api_url or getenv('SCOPE3AI_API_URL') or DEFAULT_API_URL

client property

client: ClientType

Obtain an httpx client for synchronous or asynchronous operation with the necessary authentication headers included.

create_client

create_client() -> ClientType

ClientCommands

Base class that implements the command methods for interacting with the Scope3AI API. The execute_request method must be implemented by subclasses to handle the actual HTTP requests.

Methods:

add_model_alias

add_model_alias(model_id: str, content: dict, with_response: Optional[bool] = True) -> None

Add a new alias to a model

calculate_impact_big_query

calculate_impact_big_query(content: ImpactBigQueryRequest, with_response: Optional[bool] = True) -> ImpactBigQueryResponse

Calculate AI model impact metrics for BigQuery

create_gpu

create_gpu(content: GPUCreateRequest, with_response: Optional[bool] = True) -> GPU

Create a GPU

create_model

create_model(content: ModelCreateRequest, with_response: Optional[bool] = True) -> Model

Create a model

create_node

create_node(content: NodeCreateRequest, with_response: Optional[bool] = True) -> Node

Create a custom node

delete_gpu

delete_gpu(gpu_id: str, with_response: Optional[bool] = True) -> None

Delete a GPU

delete_model

delete_model(model_id: str, with_response: Optional[bool] = True) -> None

Delete a model

delete_node

delete_node(node_id: str, with_response: Optional[bool] = True) -> None

Delete a node (custom nodes only, unless admin)

execute_request

execute_request(*args, **kwargs) -> Any

Execute an HTTP request to the Scope3AI API. Must be implemented by subclasses to handle synchronous or asynchronous requests.

get_gpu

get_gpu(gpu_id: str, with_response: Optional[bool] = True) -> GPU

Get a specific GPU (global or custom)

get_impact

get_impact(content: ImpactRequest, debug: Optional[bool] = None, with_response: Optional[bool] = True) -> ImpactResponse

Get impact metrics for a task

get_model

get_model(model_id: str, with_response: Optional[bool] = True) -> Model

Get a specific model (global or custom)

get_node

get_node(node_id: str, with_response: Optional[bool] = True) -> Node

Get a specific node (global or custom)

list_gpus

list_gpus(with_response: Optional[bool] = True) -> GPUResponse

List GPUs

list_models

list_models(family: Optional[Family] = None, with_response: Optional[bool] = True) -> ModelResponse

List models

list_nodes

list_nodes(service: Optional[str] = None, cloud: Optional[str] = None, custom: Optional[bool] = None, gpu: Optional[str] = None, instance: Optional[str] = None, with_response: Optional[bool] = True) -> NodeResponse

List nodes (both global and custom)

reload

reload(with_response: Optional[bool] = True) -> StatusResponse

remove_model_alias

remove_model_alias(model_id: str, alias: str, with_response: Optional[bool] = True) -> None

Remove an alias from a model

status

status(with_response: Optional[bool] = True) -> StatusResponse

update_gpu

update_gpu(gpu_id: str, content: GPUUpdateRequest, with_response: Optional[bool] = True) -> GPU

Update a GPU

update_model

update_model(model_id: str, content: ModelUpdateRequest, with_response: Optional[bool] = True) -> Model

Update a model

update_node

update_node(node_id: str, content: NodeUpdateRequest, with_response: Optional[bool] = True) -> Node

Update a node (custom nodes only, unless admin)