AimableDocs
DocsAPI Reference

Space Allowed Models

Introduction to Space Allowed Models

The "space-allowed-models" domain in the FastAPI API (v0.1.0) is designed to manage the models that are permitted within a specific space. This functionality is crucial for controlling access and ensuring that only authorized models are available for use within a given context. By managing space-allowed models, developers can maintain organized and secure environments tailored to specific needs or projects.

Key Concepts

Space

A "space" is a logical grouping or environment where specific models can be utilized. Each space is identified by a unique space_id.

Model

A "model" refers to a computational or data model that can be used within a space. Models are identified by tenant_model_id.

Idempotency

Idempotency ensures that repeated requests have the same effect as a single request, preventing duplicate operations. This is particularly important for POST requests where the Idempotency-Key header is required.

Common Workflows

Listing Allowed Models in a Space

To retrieve a list of models allowed in a specific space, use the GET endpoint. This is useful for auditing or verifying which models are currently permitted.

Example:

curl -X GET "https://api.example.com/v1/spaces/{space_id}/models" \
  -H "X-API-Key: your_api_key"

Adding a Model to a Space

To add a model to a space, use the POST endpoint. This action requires an Idempotency-Key to ensure the operation is not duplicated.

Example:

curl -X POST "https://api.example.com/v1/spaces/{space_id}/models" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: unique_key" \
  -H "X-API-Key: your_api_key" \
  -d '{"model_id": "new_model_id"}'

Removing a Model from a Space

To remove a model from a space, use the DELETE endpoint. This operation is straightforward and does not require a request body.

Example:

curl -X DELETE "https://api.example.com/v1/spaces/{space_id}/models/{tenant_model_id}" \
  -H "X-API-Key: your_api_key"

Important Considerations

Authentication

Most operations require an X-API-Key for authentication. Ensure that this key is kept secure and is included in the header of your requests.

Pagination

When listing models, the response may be paginated. Use the limit and cursor query parameters to control the number of results and navigate through pages.

Error Handling

Handle errors gracefully by checking response status codes. For example, a 404 status code indicates that the specified space or model does not exist, while a 401 status code suggests authentication issues.

By understanding and utilizing these endpoints effectively, developers can manage model access within spaces efficiently, ensuring that only the appropriate models are available for use in specific contexts.