Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ Set `OTARI_AI_TOKEN` (or the legacy alias `GATEWAY_PLATFORM_TOKEN`) and `OtariCl

**Self-hosted mode**

Targets a gateway you run yourself. The API key is sent via the custom `Otari-Key` header, and an explicit `api_base` is required. Follow the setup in the [otari repo](https://github.com/mozilla-ai/otari), then point the SDK at your gateway:
Targets a gateway you run yourself. The API key is sent via the custom `Otari-Key` header, and an explicit `api_base` is required. Follow the setup in the [otari repo](https://github.com/mozilla-ai/otari), then point the SDK at your gateway.

`api_base` is the gateway **origin**, with no path prefix. The SDK appends the API root, `/api/v1`, itself, so `http://localhost:8000` reaches `http://localhost:8000/api/v1/chat/completions`. Passing a value that already ends in `/api/v1` raises `ValueError`.

```python
from otari import OtariClient
Expand All @@ -117,7 +119,7 @@ Set `GATEWAY_API_BASE` and `GATEWAY_API_KEY` and `OtariClient()` picks them up a
|----------|------|---------|
| `OTARI_AI_TOKEN` | Platform | Platform token, sent as `Authorization: Bearer …`. |
| `GATEWAY_PLATFORM_TOKEN` | Platform | Legacy alias for `OTARI_AI_TOKEN` (lower precedence). |
| `GATEWAY_API_BASE` | Self-hosted | Base URL of the gateway (required in self-hosted mode). |
| `GATEWAY_API_BASE` | Self-hosted | Origin of the gateway, with no path prefix (required in self-hosted mode). |
| `GATEWAY_API_KEY` | Self-hosted | API key, sent via the `Otari-Key` header. |
| `GATEWAY_ADMIN_KEY` | Either | Admin/master key for the control-plane endpoints. |

Expand Down
22 changes: 15 additions & 7 deletions src/otari/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@

_DEFAULT_PLATFORM_API_BASE = "https://api.otari.ai"

# Single owner of the API path prefix. Every Otari API path hangs off this root;
# the generated core's operation paths already carry it.
API_ROOT = "/api/v1"

_ENV_API_BASE = "GATEWAY_API_BASE"
_ENV_API_KEY = "GATEWAY_API_KEY"
# Matches the gateway server's own alias chain (OTARI_AI_TOKEN preferred).
Expand Down Expand Up @@ -106,15 +110,19 @@ def __init__(
)
raise ValueError(msg)

# Ensure the base URL includes /v1 since the gateway expects
# OpenAI-compatible paths like /v1/chat/completions.
# api_base is an origin. The API root is appended here for the
# hand-written request helpers; the generated core carries it in its
# own operation paths and so is configured with the bare origin.
cleaned = raw_base.rstrip("/")
api_base_url = cleaned if cleaned.endswith("/v1") else f"{cleaned}/v1"
if cleaned.endswith(API_ROOT):
msg = (
f"api_base must be the gateway origin, without the {API_ROOT} "
f"path prefix. Pass {cleaned.removesuffix(API_ROOT).rstrip('/')!r} instead."
)
raise ValueError(msg)

self._base_url = api_base_url
# The generated core's operation paths already include the ``/v1``
# prefix, so the generated ``Configuration.host`` is the gateway root.
self._gateway_root_url = api_base_url.removesuffix("/v1")
self._gateway_root_url = cleaned
self._base_url = f"{self._gateway_root_url}{API_ROOT}"

headers: dict[str, str] = {**(default_headers or {})}

Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/_spec_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__spec_version__ = "0.6.0"
__spec_version__ = "0.6.1"
2 changes: 1 addition & 1 deletion src/otari/_client/api/admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/agent_telemetry_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
25 changes: 21 additions & 4 deletions src/otari/_client/api/aliases_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down Expand Up @@ -892,6 +892,7 @@ def _aliases_list_aliases_serialize(
def aliases_list_visible_aliases(
self,
limit: Annotated[Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]], Field(description="Maximum entries to return, stored and config-file together.")] = None,
workspace_id: Annotated[Optional[UUID], Field(description="Only stored entries in this workspace. Config-file entries are always included, being deployment-wide. Omit for every workspace this caller may see.")] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -907,10 +908,12 @@ def aliases_list_visible_aliases(
) -> List[AliasResponse]:
"""List Visible Aliases

List the aliases in force in the workspaces this caller may see. The policies list's sibling, over ``model_aliases``, and scoped the same way: stored rows from the caller's visible workspaces, plus the config-file aliases, which are deployment-wide.
List the aliases in force in the workspaces this caller may see. The policies list's sibling, over ``model_aliases``, and scoped the same way: stored rows from the caller's visible workspaces, plus the config-file aliases, which are deployment-wide, and narrowed to one workspace when ``workspace_id`` names one.

:param limit: Maximum entries to return, stored and config-file together.
:type limit: int
:param workspace_id: Only stored entries in this workspace. Config-file entries are always included, being deployment-wide. Omit for every workspace this caller may see.
:type workspace_id: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
Expand All @@ -935,6 +938,7 @@ def aliases_list_visible_aliases(

_param = self._aliases_list_visible_aliases_serialize(
limit=limit,
workspace_id=workspace_id,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
Expand All @@ -960,6 +964,7 @@ def aliases_list_visible_aliases(
def aliases_list_visible_aliases_with_http_info(
self,
limit: Annotated[Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]], Field(description="Maximum entries to return, stored and config-file together.")] = None,
workspace_id: Annotated[Optional[UUID], Field(description="Only stored entries in this workspace. Config-file entries are always included, being deployment-wide. Omit for every workspace this caller may see.")] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -975,10 +980,12 @@ def aliases_list_visible_aliases_with_http_info(
) -> ApiResponse[List[AliasResponse]]:
"""List Visible Aliases

List the aliases in force in the workspaces this caller may see. The policies list's sibling, over ``model_aliases``, and scoped the same way: stored rows from the caller's visible workspaces, plus the config-file aliases, which are deployment-wide.
List the aliases in force in the workspaces this caller may see. The policies list's sibling, over ``model_aliases``, and scoped the same way: stored rows from the caller's visible workspaces, plus the config-file aliases, which are deployment-wide, and narrowed to one workspace when ``workspace_id`` names one.

:param limit: Maximum entries to return, stored and config-file together.
:type limit: int
:param workspace_id: Only stored entries in this workspace. Config-file entries are always included, being deployment-wide. Omit for every workspace this caller may see.
:type workspace_id: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
Expand All @@ -1003,6 +1010,7 @@ def aliases_list_visible_aliases_with_http_info(

_param = self._aliases_list_visible_aliases_serialize(
limit=limit,
workspace_id=workspace_id,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
Expand All @@ -1028,6 +1036,7 @@ def aliases_list_visible_aliases_with_http_info(
def aliases_list_visible_aliases_without_preload_content(
self,
limit: Annotated[Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]], Field(description="Maximum entries to return, stored and config-file together.")] = None,
workspace_id: Annotated[Optional[UUID], Field(description="Only stored entries in this workspace. Config-file entries are always included, being deployment-wide. Omit for every workspace this caller may see.")] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -1043,10 +1052,12 @@ def aliases_list_visible_aliases_without_preload_content(
) -> RESTResponseType:
"""List Visible Aliases

List the aliases in force in the workspaces this caller may see. The policies list's sibling, over ``model_aliases``, and scoped the same way: stored rows from the caller's visible workspaces, plus the config-file aliases, which are deployment-wide.
List the aliases in force in the workspaces this caller may see. The policies list's sibling, over ``model_aliases``, and scoped the same way: stored rows from the caller's visible workspaces, plus the config-file aliases, which are deployment-wide, and narrowed to one workspace when ``workspace_id`` names one.

:param limit: Maximum entries to return, stored and config-file together.
:type limit: int
:param workspace_id: Only stored entries in this workspace. Config-file entries are always included, being deployment-wide. Omit for every workspace this caller may see.
:type workspace_id: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
Expand All @@ -1071,6 +1082,7 @@ def aliases_list_visible_aliases_without_preload_content(

_param = self._aliases_list_visible_aliases_serialize(
limit=limit,
workspace_id=workspace_id,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
Expand All @@ -1091,6 +1103,7 @@ def aliases_list_visible_aliases_without_preload_content(
def _aliases_list_visible_aliases_serialize(
self,
limit,
workspace_id,
_request_auth,
_content_type,
_headers,
Expand All @@ -1117,6 +1130,10 @@ def _aliases_list_visible_aliases_serialize(

_query_params.append(('limit', limit))

if workspace_id is not None:

_query_params.append(('workspace_id', workspace_id))

# process the header parameters
# process the form parameters
# process the body parameter
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/audio_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/auth_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/batches_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/bootstrap_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/budgets_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/catalog_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/embeddings_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/files_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/health_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/images_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/invitations_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/keys_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/mcp_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/mcp_servers_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/messages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/models_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/moderations_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/organization_budgets_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/organization_guardrails_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
2 changes: 1 addition & 1 deletion src/otari/_client/api/organization_keys_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Otari, an OpenAI-compatible LLM gateway with API key management

The version of the OpenAPI document: 0.6.0
The version of the OpenAPI document: 0.6.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down
Loading
Loading