Anthropic API client library for kiarina namespace
Project description
kiarina-lib-anthropic
English | 日本語
[!NOTE] What is this? A package for managing Anthropic API credentials and endpoints with pydantic-settings-manager.
Dependencies
| Package | Version | License |
|---|---|---|
| Pydantic Settings | >=2.10.1 |
MIT |
| pydantic-settings-manager | >=3.2.0 |
MIT |
The Anthropic Python SDK is not included as a dependency. Add it to the application that creates the client.
Installation
pip install kiarina-lib-anthropic
Features
- Configuring an Anthropic Client Store an API key and optional base URL as typed settings.
- Managing Multiple Configurations Switch between named settings for multiple projects or environments.
- Loading Environment Variables
Load environment variables with the
KIARINA_LIB_ANTHROPIC_prefix. - Protecting API Keys
Store the API key as
SecretStrto prevent exposure in normal string representations.
Configuring an Anthropic Client
Convert AnthropicSettings into arguments for an Anthropic SDK client.
from anthropic import Anthropic
from kiarina.lib.anthropic import AnthropicSettings
settings = AnthropicSettings(api_key="sk-ant-...")
client = Anthropic(
api_key=(
settings.api_key.get_secret_value()
if settings.api_key is not None
else None
),
base_url=settings.base_url,
)
Both api_key and base_url are optional. When omitted, behavior is determined by the client that receives the settings.
Managing Multiple Configurations
settings_manager uses multiple-settings mode. Place named settings under configs.
kiarina.lib.anthropic:
default: production
configs:
development:
api_key: sk-ant-development
production:
api_key: sk-ant-production
import yaml
from pydantic_settings_manager import load_user_configs
from kiarina.lib.anthropic import settings_manager
with open("config.yaml", encoding="utf-8") as file:
load_user_configs(yaml.safe_load(file) or {})
settings = settings_manager.get_settings("production")
To configure only this package directly, assign settings_manager.user_config.
from kiarina.lib.anthropic import settings_manager
settings_manager.user_config = {
"default": "development",
"configs": {
"development": {"api_key": "sk-ant-development"},
"production": {"api_key": "sk-ant-production"},
},
}
Loading Environment Variables
Load a single configuration from environment variables.
export KIARINA_LIB_ANTHROPIC_API_KEY="sk-ant-..."
export KIARINA_LIB_ANTHROPIC_BASE_URL="https://api.anthropic.com"
from kiarina.lib.anthropic import AnthropicSettings
settings = AnthropicSettings()
Protecting API Keys
api_key is a SecretStr. Extract its value explicitly only where required.
api_key = (
settings.api_key.get_secret_value()
if settings.api_key is not None
else None
)
API Reference
kiarina.lib.anthropic
from kiarina.lib.anthropic import (
AnthropicSettings,
settings_manager,
)
AnthropicSettings
class AnthropicSettings(BaseSettings):
def __init__(
self,
*,
api_key: SecretStr | None = None,
base_url: str | None = None,
) -> None: ...
Anthropic client settings.
Fields
api_key(SecretStr | None): Anthropic API key.base_url(str | None): Base URL for the Anthropic API.
settings_manager
settings_manager: SettingsManager[AnthropicSettings]
Global instance that manages named Anthropic client settings.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kiarina_lib_anthropic-2.3.1.tar.gz.
File metadata
- Download URL: kiarina_lib_anthropic-2.3.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e0fe1de2d4834e1b40cd862c1949fa6ee747016fc13918e5c43a74b1fa6588a
|
|
| MD5 |
a7fb778189fe01d7c4c5d168946f04f0
|
|
| BLAKE2b-256 |
998e3278ed0656282667e2208802c3b08cee078ffa00ff0174cf498047bafc76
|
Provenance
The following attestation bundles were made for kiarina_lib_anthropic-2.3.1.tar.gz:
Publisher:
release-pypi.yml on kiarina/kiarina-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiarina_lib_anthropic-2.3.1.tar.gz -
Subject digest:
8e0fe1de2d4834e1b40cd862c1949fa6ee747016fc13918e5c43a74b1fa6588a - Sigstore transparency entry: 2044312792
- Sigstore integration time:
-
Permalink:
kiarina/kiarina-python@443dbb48340706ef8cf35551de167d64bc11ee82 -
Branch / Tag:
refs/tags/v2.3.1 - Owner: https://github.com/kiarina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@443dbb48340706ef8cf35551de167d64bc11ee82 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kiarina_lib_anthropic-2.3.1-py3-none-any.whl.
File metadata
- Download URL: kiarina_lib_anthropic-2.3.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36d31e88441bbfecfebf5e167d941ddca267c51170fcd03937f2bca268c585fc
|
|
| MD5 |
a201e998f3965cac36825303bec37bff
|
|
| BLAKE2b-256 |
720e62b4a90b16609a7749badb51cab676c86aa3fa47de8c056e39d8eeb8fc92
|
Provenance
The following attestation bundles were made for kiarina_lib_anthropic-2.3.1-py3-none-any.whl:
Publisher:
release-pypi.yml on kiarina/kiarina-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiarina_lib_anthropic-2.3.1-py3-none-any.whl -
Subject digest:
36d31e88441bbfecfebf5e167d941ddca267c51170fcd03937f2bca268c585fc - Sigstore transparency entry: 2044313246
- Sigstore integration time:
-
Permalink:
kiarina/kiarina-python@443dbb48340706ef8cf35551de167d64bc11ee82 -
Branch / Tag:
refs/tags/v2.3.1 - Owner: https://github.com/kiarina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@443dbb48340706ef8cf35551de167d64bc11ee82 -
Trigger Event:
push
-
Statement type: