The Secret AI SDK provides a simple and convenient way to access Secret Confidential AI models. With this SDK, you can easily integrate Secret's AI capabilities into your own applications and services.
The Secret AI SDK is a Python library that enables access to Secret Confidential AI models. The SDK provides a simple and intuitive API that allows you to send requests to Secret's AI models and receive responses in a variety of formats.
- Access to Secret Confidential AI models via a clean, Pythonic interface
- Simple authentication through API keys
- Support for streaming responses
- Flexible model selection and configuration
- Automatic handling of connections to the Secret Network
secret-ai-sdk
has dependencies specified in the pyproject.toml
file, with one external dependency:
- You may need to install
secret-sdk
separately:pip install 'secret-sdk>=1.8.1'
To install the Secret AI SDK:
pip install secret-ai-sdk
from secret_ai_sdk.secret_ai import ChatSecret
from secret_ai_sdk.secret import Secret
# Initialize the Secret client
secret_client = Secret()
# Get all models registered with the smart contracts
models = secret_client.get_models()
# For your chosen model, get a list of LLM instance URLs
urls = secret_client.get_urls(model=models[0])
# Create the AI client with specific parameters
secret_ai_llm = ChatSecret(
base_url=urls[0], # Choose a specific URL
model=models[0], # Your selected model
temperature=1.0
)
# Define your messages
messages = [
("system", "You are a helpful assistant that translates English to French."),
("human", "I love programming."),
]
# Invoke the LLM (with streaming disabled)
response = secret_ai_llm.invoke(messages, stream=False)
print(response.content)
To use the Secret AI SDK, you need your own Secret AI API Key. Visit SecreAI Development portal: https://aidev.scrtlabs.com/.
Set your API key as an environment variable:
export SECRET_AI_API_KEY='YOUR_API_KEY'
If you experience issues with the default node URL, you can manually specify one:
from secret_ai_sdk.secret import Secret
# Option 1: Directly in code
secret_client = Secret(chain_id='pulsar-3', node_url='YOUR_LCD_NODE_URL')
# Option 2: Using an environment variable
# export SECRET_NODE_URL='YOUR_LCD_NODE_URL'
For available endpoints and LCD nodes, see the Secret Network Documentation.
For streaming implementation examples, refer to the example.py
file included in the package.
For comprehensive API documentation, please visit our official documentation.
The Secret AI SDK is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions, please open an issue on our GitHub repository.