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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk-endpoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
POST /v1/chat/completions
POST /v1/responses
POST /v1/messages
POST /v1/messages/count_tokens
POST /v1/embeddings
POST /v1/moderations
POST /v1/rerank
Expand Down
6 changes: 6 additions & 0 deletions src/otari/_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
"Content8",
"Content9Inner",
"ContentAnyOfInner",
"CountTokensRequest",
"CountTokensResponse",
"CreateBatchRequest",
"CreateBudgetRequest",
"CreateEmbeddingResponse",
Expand Down Expand Up @@ -195,6 +197,7 @@
"SetPricingRequest",
"Source",
"System",
"System1",
"ToolCallsInner",
"ToolChoice",
"UpdateBudgetRequest",
Expand Down Expand Up @@ -284,6 +287,8 @@
from otari._client.models.content8 import Content8 as Content8
from otari._client.models.content9_inner import Content9Inner as Content9Inner
from otari._client.models.content_any_of_inner import ContentAnyOfInner as ContentAnyOfInner
from otari._client.models.count_tokens_request import CountTokensRequest as CountTokensRequest
from otari._client.models.count_tokens_response import CountTokensResponse as CountTokensResponse
from otari._client.models.create_batch_request import CreateBatchRequest as CreateBatchRequest
from otari._client.models.create_budget_request import CreateBudgetRequest as CreateBudgetRequest
from otari._client.models.create_embedding_response import CreateEmbeddingResponse as CreateEmbeddingResponse
Expand Down Expand Up @@ -388,6 +393,7 @@
from otari._client.models.set_pricing_request import SetPricingRequest as SetPricingRequest
from otari._client.models.source import Source as Source
from otari._client.models.system import System as System
from otari._client.models.system1 import System1 as System1
from otari._client.models.tool_calls_inner import ToolCallsInner as ToolCallsInner
from otari._client.models.tool_choice import ToolChoice as ToolChoice
from otari._client.models.update_budget_request import UpdateBudgetRequest as UpdateBudgetRequest
Expand Down
278 changes: 278 additions & 0 deletions src/otari/_client/api/messages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from otari._client.models.count_tokens_request import CountTokensRequest
from otari._client.models.count_tokens_response import CountTokensResponse
from otari._client.models.message_response import MessageResponse
from otari._client.models.messages_request import MessagesRequest

Expand All @@ -36,6 +38,282 @@ def __init__(self, api_client=None) -> None:
self.api_client = api_client


@validate_call
def count_message_tokens_v1_messages_count_tokens_post(
self,
count_tokens_request: CountTokensRequest,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> CountTokensResponse:
"""Count Message Tokens

Anthropic ``/v1/messages/count_tokens``-compatible endpoint. Returns ``{\"input_tokens\": N}`` without contacting an upstream provider: counting is local, so there is no budget reservation, pricing, or usage logging. Authentication mirrors :func:`create_message` — platform mode resolves the caller's token against the platform, standalone mode validates the API key — so the endpoint is not an open token-counting oracle.

:param count_tokens_request: (required)
:type count_tokens_request: CountTokensRequest
: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
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._count_message_tokens_v1_messages_count_tokens_post_serialize(
count_tokens_request=count_tokens_request,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "CountTokensResponse",
'422': "HTTPValidationError",
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
).data


@validate_call
def count_message_tokens_v1_messages_count_tokens_post_with_http_info(
self,
count_tokens_request: CountTokensRequest,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[CountTokensResponse]:
"""Count Message Tokens

Anthropic ``/v1/messages/count_tokens``-compatible endpoint. Returns ``{\"input_tokens\": N}`` without contacting an upstream provider: counting is local, so there is no budget reservation, pricing, or usage logging. Authentication mirrors :func:`create_message` — platform mode resolves the caller's token against the platform, standalone mode validates the API key — so the endpoint is not an open token-counting oracle.

:param count_tokens_request: (required)
:type count_tokens_request: CountTokensRequest
: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
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._count_message_tokens_v1_messages_count_tokens_post_serialize(
count_tokens_request=count_tokens_request,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "CountTokensResponse",
'422': "HTTPValidationError",
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
)


@validate_call
def count_message_tokens_v1_messages_count_tokens_post_without_preload_content(
self,
count_tokens_request: CountTokensRequest,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> RESTResponseType:
"""Count Message Tokens

Anthropic ``/v1/messages/count_tokens``-compatible endpoint. Returns ``{\"input_tokens\": N}`` without contacting an upstream provider: counting is local, so there is no budget reservation, pricing, or usage logging. Authentication mirrors :func:`create_message` — platform mode resolves the caller's token against the platform, standalone mode validates the API key — so the endpoint is not an open token-counting oracle.

:param count_tokens_request: (required)
:type count_tokens_request: CountTokensRequest
: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
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501

_param = self._count_message_tokens_v1_messages_count_tokens_post_serialize(
count_tokens_request=count_tokens_request,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "CountTokensResponse",
'422': "HTTPValidationError",
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
return response_data.response


def _count_message_tokens_v1_messages_count_tokens_post_serialize(
self,
count_tokens_request,
_request_auth,
_content_type,
_headers,
_host_index,
) -> RequestSerialized:

_host = None

_collection_formats: Dict[str, str] = {
}

_path_params: Dict[str, str] = {}
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_body_params: Optional[bytes] = None

# process the path parameters
# process the query parameters
# process the header parameters
# process the form parameters
# process the body parameter
if count_tokens_request is not None:
_body_params = count_tokens_request


# set the HTTP header `Accept`
if 'Accept' not in _header_params:
_header_params['Accept'] = self.api_client.select_header_accept(
[
'application/json'
]
)

# set the HTTP header `Content-Type`
if _content_type:
_header_params['Content-Type'] = _content_type
else:
_default_content_type = (
self.api_client.select_header_content_type(
[
'application/json'
]
)
)
if _default_content_type is not None:
_header_params['Content-Type'] = _default_content_type

# authentication setting
_auth_settings: List[str] = [
]

return self.api_client.param_serialize(
method='POST',
resource_path='/v1/messages/count_tokens',
path_params=_path_params,
query_params=_query_params,
header_params=_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
auth_settings=_auth_settings,
collection_formats=_collection_formats,
_host=_host,
_request_auth=_request_auth
)




@validate_call
def create_message_v1_messages_post(
self,
Expand Down
3 changes: 3 additions & 0 deletions src/otari/_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
from otari._client.models.content8 import Content8
from otari._client.models.content9_inner import Content9Inner
from otari._client.models.content_any_of_inner import ContentAnyOfInner
from otari._client.models.count_tokens_request import CountTokensRequest
from otari._client.models.count_tokens_response import CountTokensResponse
from otari._client.models.create_batch_request import CreateBatchRequest
from otari._client.models.create_budget_request import CreateBudgetRequest
from otari._client.models.create_embedding_response import CreateEmbeddingResponse
Expand Down Expand Up @@ -165,6 +167,7 @@
from otari._client.models.set_pricing_request import SetPricingRequest
from otari._client.models.source import Source
from otari._client.models.system import System
from otari._client.models.system1 import System1
from otari._client.models.tool_calls_inner import ToolCallsInner
from otari._client.models.tool_choice import ToolChoice
from otari._client.models.update_budget_request import UpdateBudgetRequest
Expand Down
Loading
Loading