> For the complete documentation index, see [llms.txt](https://docs.scrt.network/secret-network-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scrt.network/secret-network-documentation/secret-ai/sdk/setting-up-your-environment/api-reference.md).

# API Reference

### API Reference

#### Secret Class

Main client for interacting with Secret Network smart contracts.

```python
class Secret:
    def __init__(self, chain_id: str = None, node_url: str = None)
    def get_models(self) -> List[str]
    def get_urls(self, model: str) -> List[str]
```

#### ChatSecret Class

LangChain-compatible chat interface for text generation.

```python
class ChatSecret(ChatOllama):
    def __init__(self, base_url: str, model: str, **kwargs)
    def invoke(self, messages: List[Tuple[str, str]], **kwargs) -> str
    def stream(self, messages: List[Tuple[str, str]], **kwargs) -> Iterator[str]
```

#### VoiceSecret Class

Unified interface for speech-to-text and text-to-speech operations.

```python
class VoiceSecret:
    def __init__(self, stt_url: str, tts_url: str, api_key: str = None)
    def transcribe_audio(self, audio_file: Union[str, Path, BinaryIO]) -> Dict[str, Any]
    def synthesize_speech(self, text: str, model: str = "tts-1", 
                         voice: str = "af_alloy", **kwargs) -> bytes
    def check_stt_health(self) -> bool
    def check_tts_health(self) -> bool
    def get_available_voices(self) -> List[str]
    def get_available_models(self) -> List[Dict[str, Any]]
```

#### Enhanced Clients

Advanced clients with retry logic and enhanced error handling.

```python
class EnhancedSecretAIClient(OllamaClient):
    def __init__(self, host: str = None, api_key: str = None, 
                 timeout: float = None, max_retries: int = None, **kwargs)

class EnhancedSecretAIAsyncClient(OllamaAsyncClient):
    def __init__(self, host: str = None, api_key: str = None, 
                 timeout: float = None, max_retries: int = None, **kwargs)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scrt.network/secret-network-documentation/secret-ai/sdk/setting-up-your-environment/api-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
