sarvam

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 8 Imported by: 0

README ΒΆ

SarvamAI Go SDK

Go Reference Go Report Card Go Version License

An unofficial Go SDK for the Sarvam AI APIs, providing easy access to Indian language AI services including translation, text-to-speech, chat completions, and language identification.

⚠️ Breaking Changes Notice: This SDK is currently in pre-v1 development. Breaking changes may occur until v1.0.0 is released. Please pin your dependency version if you need stability in production environments.

🌟 API Parity (wip)

  • Text Translation
  • Language Identification
  • Text-to-Speech
  • Chat Completions
  • Transliteration
  • Speech to text
  • Speech to text translation

πŸš€ Quick Start

Installation
go get code.abhai.dev/sarvam
Basic Usage

The SDK provides both instance-based and package-level APIs for convenience.

package main

import (
    "fmt"
    "log"
    "os"
    
    "code.abhai.dev/sarvam"
)

func main() {
    // Set API key (or set SARVAM_API_KEY environment variable)
    sarvam.SetAPIKey("your-api-key-here")
    
    // Use package-level functions directly
    result, err := sarvam.SpeechToText(sarvam.SpeechToTextParams{
        FilePath: "audio.wav",
        Model:    &sarvam.SpeechToTextModelSaarikaV2dot5,
    })
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Println("Transcript:", result.Transcript)
}
package main

import (
    "fmt"
    "log"
    
    "code.abhai.dev/sarvam"
)

func main() {
    // Create a client instance
    client := sarvam.NewClient("your-api-key-here")
    
    // Use the client instance
    result, err := client.SpeechToText(sarvam.SpeechToTextParams{
        FilePath: "audio.wav",
        Model:    &sarvam.SpeechToTextModelSaarikaV2dot5,
    })
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Println("Transcript:", result.Transcript)
}
Environment Variable

You can set the SARVAM_API_KEY environment variable instead of calling SetAPIKey():

export SARVAM_API_KEY="your-api-key-here"

The SDK will automatically pick up this environment variable on initialization.

Available Package-Level Functions

The SDK provides the following package-level functions that use the default client:

Speech & Audio
  • sarvam.SpeechToText(params) - Convert speech to text
  • sarvam.SpeechToTextTranslate(params) - Convert speech to text with translation to English
  • sarvam.TextToSpeech(params) - Convert text to speech
Chat & AI
  • sarvam.ChatCompletion(request) - Generate chat completions
  • sarvam.SimpleChatCompletion(messages, model) - Generate chat completions with simplified parameters
  • sarvam.ChatCompletionWithParams(params) - Generate chat completions with custom parameters
Translation & Language
  • sarvam.Translate(input, sourceLang, targetLang) - Translate text between languages
  • sarvam.TranslateWithParams(params) - Translate text with advanced parameters
  • sarvam.IdentifyLanguage(input) - Identify the language of input text
  • sarvam.Transliterate(input, sourceLang, targetLang) - Convert text between scripts
Utility Functions
  • sarvam.SetAPIKey(key) - Set the API key for the default client
  • sarvam.GetDefaultClient() - Get the current default client instance
Error Handling

All package-level functions return appropriate errors if:

  • The default client is not initialized (call SetAPIKey() first)
  • The API key is invalid or expired
  • The request parameters are invalid
  • The API returns an error response

πŸ“– Examples

Check out the examples directory for complete working examples:

🀝 Contributing

We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup
  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

If you encounter any issues or have questions:

  1. Check the examples directory
  2. Review the API documentation
  3. Open an issue on GitHub

Disclaimer

This SDK is an unofficial client for the Sarvam API and is not affiliated with, endorsed by, or maintained by Sarvam.

All trademarks, service marks, and copyrights associated with Sarvam belong to their respective owners.

Use this SDK at your own risk. Please review and comply with Sarvam’s terms of service and API usage policies.


Made with ❀️ for the Indian AI community

Documentation ΒΆ

Overview ΒΆ

Package sarvam provides a Go client for the Sarvam AI API.

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func Ptr ΒΆ added in v0.0.2

func Ptr[T any](v T) *T

func SetAPIKey ΒΆ added in v0.0.2

func SetAPIKey(apiKey string)

SetAPIKey sets the API key for the default client and creates a new client instance

Types ΒΆ

type AudioCodec ΒΆ added in v0.0.2

type AudioCodec string
var (
	AudioCodecWav      AudioCodec = "wav"
	AudioCodecXWav     AudioCodec = "x-wav"
	AudioCodecWave     AudioCodec = "wave"
	AudioCodecMp3      AudioCodec = "mp3"
	AudioCodecMpeg     AudioCodec = "mpeg"
	AudioCodecMpeg3    AudioCodec = "mpeg3"
	AudioCodecXMp3     AudioCodec = "x-mp3"
	AudioCodecXMpeg3   AudioCodec = "x-mpeg-3"
	AudioCodecAac      AudioCodec = "aac"
	AudioCodecXAac     AudioCodec = "x-aac"
	AudioCodecAiff     AudioCodec = "aiff"
	AudioCodecXAiff    AudioCodec = "x-aiff"
	AudioCodecOgg      AudioCodec = "ogg"
	AudioCodecOpus     AudioCodec = "opus"
	AudioCodecFlac     AudioCodec = "flac"
	AudioCodecXFlac    AudioCodec = "x-flac"
	AudioCodecMp4      AudioCodec = "mp4"
	AudioCodecXM4a     AudioCodec = "x-m4a"
	AudioCodecAmr      AudioCodec = "amr"
	AudioCodecXMsWma   AudioCodec = "x-ms-wma"
	AudioCodecWebm     AudioCodec = "webm"
	AudioCodecPcmS16le AudioCodec = "pcm_s16le"
	AudioCodecPcmL16   AudioCodec = "pcm_l16"
	AudioCodecPcmRaw   AudioCodec = "pcm_raw"
)

type ChatCompletionChoice ΒΆ

type ChatCompletionChoice struct {
	FinishReason string  `json:"finish_reason"`
	Index        int     `json:"index"`
	Message      Message `json:"message"`
}

ChatCompletionChoice represents a single completion choice.

type ChatCompletionModel ΒΆ

type ChatCompletionModel string

ChatCompletionModel specifies the model to use for chat completions.

var (
	ChatCompletionModelBulbulV2 ChatCompletionModel = "bulbul:v2"
	ChatCompletionModelSarvamM  ChatCompletionModel = "sarvam-m"
)

type ChatCompletionParams ΒΆ added in v0.0.2

type ChatCompletionParams struct {
	Temperature      *float64
	TopP             *float64
	ReasoningEffort  *ReasoningEffort
	MaxTokens        *int
	Stream           *bool
	Stop             []string // string or []string. TODO: Find a way to make this more type safe.
	N                *int
	Seed             *int64
	FrequencyPenalty *float64
	PresencePenalty  *float64
	WikiGrounding    *bool
}

ChatCompletionParams represents the parameters for chat completions.

type ChatCompletionResponse ΒΆ

type ChatCompletionResponse struct {
	ID      string                 `json:"id"`
	Choices []ChatCompletionChoice `json:"choices"`
	Created int64                  `json:"created"`
	Model   string                 `json:"model"`
	Object  string                 `json:"object"`
	Usage   *Usage                 `json:"usage"`
}

ChatCompletionResponse represents the response from the chat completions API.

func ChatCompletion ΒΆ added in v0.0.2

func ChatCompletion(messages []Message, model ChatCompletionModel, req *ChatCompletionParams) (*ChatCompletionResponse, error)

ChatCompletion is a package-level function that uses the default client

func (*ChatCompletionResponse) GetChoiceContent ΒΆ

func (r *ChatCompletionResponse) GetChoiceContent(index int) string

GetChoiceContent returns the content of a specific choice by index.

func (*ChatCompletionResponse) GetFirstChoiceContent ΒΆ

func (r *ChatCompletionResponse) GetFirstChoiceContent() string

GetFirstChoiceContent returns the content of the first choice from the response.

type Client ΒΆ

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Sarvam AI API client.

func GetDefaultClient ΒΆ added in v0.0.2

func GetDefaultClient() *Client

GetDefaultClient returns the default client instance

func NewClient ΒΆ

func NewClient(apiKey string) *Client

NewClient creates a new Sarvam AI client with the provided API key.

func (*Client) ChatCompletion ΒΆ

func (c *Client) ChatCompletion(messages []Message, model ChatCompletionModel, req *ChatCompletionParams) (*ChatCompletionResponse, error)

ChatCompletion creates a chat completion using the Sarvam AI API.

func (*Client) IdentifyLanguage ΒΆ

func (c *Client) IdentifyLanguage(input string) (*LanguageIdentificationResponse, error)

IdentifyLanguage identifies the language (e.g., en-IN, hi-IN) and script (e.g., Latin, Devanagari) of the input text, supporting multiple languages.

func (*Client) SetBaseURL ΒΆ

func (c *Client) SetBaseURL(baseURL string)

SetBaseURL allows customization of the API endpoint URL.

func (*Client) SpeechToText ΒΆ

func (c *Client) SpeechToText(speech io.Reader, params SpeechToTextParams) (*SpeechToTextResponse, error)

SpeechToText converts speech from an audio file to text.

func (*Client) SpeechToTextTranslate ΒΆ

func (c *Client) SpeechToTextTranslate(speech io.Reader, params SpeechToTextTranslateParams) (*SpeechToTextTranslateResponse, error)

SpeechToTextTranslate automatically detects the input language, transcribes the speech, and translates the text to English.

func (*Client) TextToSpeech ΒΆ

func (c *Client) TextToSpeech(text string, targetLanguage Language, params TextToSpeechParams) (*TextToSpeechResponse, error)

TextToSpeech converts text to speech in the specified language.

func (*Client) Translate ΒΆ

func (c *Client) Translate(input string, sourceLanguageCode, targetLanguageCode Language, params *TranslateParams) (*TranslationResponse, error)

TranslateWithParams converts text from one language to another with custom parameters.

func (*Client) Transliterate ΒΆ

func (c *Client) Transliterate(input string, sourceLanguage Language, targetLanguage Language, params *TransliterateParams) (*TransliterationResponse, error)

Transliterate converts text from one script to another while preserving the original pronunciation.

type DiarizedEntry ΒΆ

type DiarizedEntry struct {
	Transcript       string  `json:"transcript"`
	StartTimeSeconds float64 `json:"start_time_seconds"`
	EndTimeSeconds   float64 `json:"end_time_seconds"`
	SpeakerID        string  `json:"speaker_id"`
}

DiarizedEntry represents a single speaker's transcript segment.

type DiarizedTranscript ΒΆ

type DiarizedTranscript struct {
	Entries []DiarizedEntry `json:"entries"`
}

DiarizedTranscript represents the complete diarized transcript.

type ErrInputTooLong ΒΆ

type ErrInputTooLong struct {
	InputLength int
	MaxLength   int
}

ErrInputTooLong is returned when the input length is greater than or equal to 1000 characters.

func (*ErrInputTooLong) Error ΒΆ

func (e *ErrInputTooLong) Error() string

type HTTPError ΒΆ

type HTTPError struct {
	StatusCode int
	Message    string
	Code       string
	RequestID  string
}

HTTPError represents an error response from the Sarvam AI API.

func (*HTTPError) Error ΒΆ

func (e *HTTPError) Error() string

Error implements the error interface for HTTPError.

type Language ΒΆ

type Language string

Language represents a supported language code.

const (
	LanguageAssamese  Language = "as-IN"
	LanguageBengali   Language = "bn-IN"
	LanguageBodo      Language = "brx-IN"
	LanguageDogri     Language = "doi-IN"
	LanguageEnglish   Language = "en-IN"
	LanguageGujarati  Language = "gu-IN"
	LanguageHindi     Language = "hi-IN"
	LanguageKannada   Language = "kn-IN"
	LanguageKashmiri  Language = "ks-IN"
	LanguageKonkani   Language = "kok-IN"
	LanguageMaithili  Language = "mai-IN"
	LanguageMalayalam Language = "ml-IN"
	LanguageManipuri  Language = "mni-IN"
	LanguageMarathi   Language = "mr-IN"
	LanguageNepali    Language = "ne-IN"
	LanguageOdia      Language = "od-IN"
	LanguagePunjabi   Language = "pa-IN"
	LanguageSanskrit  Language = "sa-IN"
	LanguageSantali   Language = "sat-IN"
	LanguageSindhi    Language = "sd-IN"
	LanguageTamil     Language = "ta-IN"
	LanguageTelugu    Language = "te-IN"
	LanguageUrdu      Language = "ur-IN"
)
const LanguageAuto Language = "auto"

func (Language) String ΒΆ

func (l Language) String() string

String returns the human-readable name of the language.

type LanguageIdentificationResponse ΒΆ added in v0.0.2

type LanguageIdentificationResponse struct {
	RequestId string
	Language  Language
	Script    Script
}

LanguageIdentification represents the result of language identification.

func IdentifyLanguage ΒΆ added in v0.0.2

func IdentifyLanguage(input string) (*LanguageIdentificationResponse, error)

IdentifyLanguage is a package-level function that uses the default client

type Message ΒΆ

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a message in the chat conversation.

func NewAssistantMessage ΒΆ added in v0.0.2

func NewAssistantMessage(content string) Message

func NewMessage ΒΆ added in v0.0.2

func NewMessage(role MessageRole, content string) Message

func NewSystemMessage ΒΆ added in v0.0.2

func NewSystemMessage(content string) Message

func NewUserMessage ΒΆ added in v0.0.2

func NewUserMessage(content string) Message

type MessageRole ΒΆ added in v0.0.2

type MessageRole string
const (
	MessageRoleSystem    MessageRole = "system"
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
)

type NumeralsFormat ΒΆ

type NumeralsFormat string

NumeralsFormat specifies the format for numerals in the translation.

const (
	// NumeralsFormatInternational represents international numeral format.
	NumeralsFormatInternational NumeralsFormat = "international"
	// NumeralsFormatNative represents native numeral format.
	NumeralsFormatNative NumeralsFormat = "native"
)

type OutputScript ΒΆ

type OutputScript string

OutputScript controls the transliteration style applied to the output text.

const (
	// OutputScriptRoman represents Roman script output.
	OutputScriptRoman OutputScript = "roman"
	// OutputScriptFullyNative represents fully native script output.
	OutputScriptFullyNative OutputScript = "fully-native"
	// OutputScriptSpokenFormInNative represents spoken form in native script output.
	OutputScriptSpokenFormInNative OutputScript = "spoken-form-in-native"
)

type ReasoningEffort ΒΆ

type ReasoningEffort string

ReasoningEffort represents the reasoning effort level for chat completions.

const (
	ReasoningEffortLow    ReasoningEffort = "low"
	ReasoningEffortMedium ReasoningEffort = "medium"
	ReasoningEffortHigh   ReasoningEffort = "high"
)

type Script ΒΆ

type Script string

Script represents a writing script.

const (
	ScriptLatin      Script = "Latn"
	ScriptDevanagari Script = "Deva"
	ScriptBengali    Script = "Beng"
	ScriptGujarati   Script = "Gujr"
	ScriptKannada    Script = "Knda"
	ScriptMalayalam  Script = "Mlym"
	ScriptOdia       Script = "Orya"
	ScriptGurmukhi   Script = "Guru"
	ScriptTamil      Script = "Taml"
	ScriptTelugu     Script = "Telu"
)

func (Script) String ΒΆ

func (s Script) String() string

type Speaker ΒΆ

type Speaker string

Speaker represents a voice/speaker for text-to-speech conversion.

var (
	SpeakerAnushka  Speaker = "anushka"
	SpeakerAbhilash Speaker = "abhilash"
	SpeakerManisha  Speaker = "manisha"
	SpeakerVidya    Speaker = "vidya"
	SpeakerArya     Speaker = "arya"
	SpeakerKarun    Speaker = "karun"
	SpeakerHitesh   Speaker = "hitesh"
)

type SpeakerGender ΒΆ

type SpeakerGender string

SpeakerGender represents the gender of the speaker for better translations.

const (
	SpeakerGenderMale   SpeakerGender = "Male"
	SpeakerGenderFemale SpeakerGender = "Female"
)

type SpeechSampleRate ΒΆ

type SpeechSampleRate int

SpeechSampleRate represents the audio sample rate for text-to-speech output.

var (
	SpeechSampleRate8000  SpeechSampleRate = 8000
	SpeechSampleRate16000 SpeechSampleRate = 16000
	SpeechSampleRate22050 SpeechSampleRate = 22050
	SpeechSampleRate24000 SpeechSampleRate = 24000
)

type SpeechToTextModel ΒΆ

type SpeechToTextModel string

SpeechToTextModel specifies the model to use for speech-to-text conversion.

var (
	SpeechToTextModelSaarikaV1     SpeechToTextModel = "saarika:v1"
	SpeechToTextModelSaarikaV2     SpeechToTextModel = "saarika:v2"
	SpeechToTextModelSaarikaV2dot5 SpeechToTextModel = "saarika:v2.5"
	SpeechToTextModelSaarikaFlash  SpeechToTextModel = "saarika:flash"
)

type SpeechToTextParams ΒΆ

type SpeechToTextParams struct {
	Model          *SpeechToTextModel // Optional: Model to use (default: saarika:v2.5)
	Language       *Language          // Optional: Language code for the input audio
	WithTimestamps *bool              // Optional: Whether to include timestamps in response
}

SpeechToTextParams contains parameters for speech-to-text conversion.

type SpeechToTextResponse ΒΆ added in v0.0.2

type SpeechToTextResponse struct {
	RequestId          string              `json:"request_id"`
	Transcript         string              `json:"transcript"`
	Timestamps         *Timestamps         `json:"timestamps,omitempty"`
	DiarizedTranscript *DiarizedTranscript `json:"diarized_transcript,omitempty"`
	Language           Language            `json:"language_code"`
}

SpeechToTextResponse represents the result of a speech-to-text operation.

func SpeechToText ΒΆ

func SpeechToText(speech io.Reader, params SpeechToTextParams) (*SpeechToTextResponse, error)

SpeechToText is a package-level function that uses the default client

func (*SpeechToTextResponse) String ΒΆ added in v0.0.2

func (s *SpeechToTextResponse) String() string

String returns the transcribed text.

type SpeechToTextTranslateModel ΒΆ

type SpeechToTextTranslateModel string

SpeechToTextTranslateModel specifies the model to use for speech-to-text with translation.

var (
	SpeechToTextTranslateModelSaarasV1     SpeechToTextTranslateModel = "saaras:v1"
	SpeechToTextTranslateModelSaarasV2     SpeechToTextTranslateModel = "saaras:v2"
	SpeechToTextTranslateModelSaarasV2dot5 SpeechToTextTranslateModel = "saaras:v2.5"
	SpeechToTextTranslateModelSaarasFlash  SpeechToTextTranslateModel = "saaras:flash"
)

type SpeechToTextTranslateParams ΒΆ

type SpeechToTextTranslateParams struct {
	Prompt     *string                     // Optional: Conversation context to boost model accuracy
	Model      *SpeechToTextTranslateModel // Optional: Model to use for speech-to-text conversion
	AudioCodec *AudioCodec                 // Optional: Audio codec to use for speech-to-text conversion
}

SpeechToTextTranslateParams contains parameters for speech-to-text-translate conversion.

type SpeechToTextTranslateResponse ΒΆ added in v0.0.2

type SpeechToTextTranslateResponse struct {
	RequestId          string
	Transcript         string
	Language           Language
	DiarizedTranscript *DiarizedTranscript
}

SpeechToTextTranslateResponse represents the result of a speech-to-text-translate operation.

func SpeechToTextTranslate ΒΆ

func SpeechToTextTranslate(speech io.Reader, params SpeechToTextTranslateParams) (*SpeechToTextTranslateResponse, error)

SpeechToTextTranslate is a package-level function that uses the default client

func (*SpeechToTextTranslateResponse) String ΒΆ added in v0.0.2

String returns the transcribed and translated text.

type SpokenFormNumeralsLanguage ΒΆ added in v0.0.2

type SpokenFormNumeralsLanguage string

SpokenFormNumeralsLanguage specifies the language for spoken form numerals.

const (
	// SpokenFormNumeralsLanguageEnglish represents English numerals in spoken form.
	SpokenFormNumeralsLanguageEnglish SpokenFormNumeralsLanguage = "english"
	// SpokenFormNumeralsLanguageNative represents native language numerals in spoken form.
	SpokenFormNumeralsLanguageNative SpokenFormNumeralsLanguage = "native"
)

type TextToSpeechModel ΒΆ

type TextToSpeechModel string

TextToSpeechModel specifies the model to use for text-to-speech conversion.

var (
	TextToSpeechModelBulbulV2 TextToSpeechModel = "bulbul:v2"
)

type TextToSpeechParams ΒΆ

type TextToSpeechParams struct {
	Speaker             *Speaker
	Pitch               *float64
	Pace                *float64
	Loudness            *float64
	SpeechSampleRate    *SpeechSampleRate
	EnablePreprocessing *bool
	Model               *TextToSpeechModel
}

TextToSpeechParams contains all parameters for text-to-speech conversion.

type TextToSpeechResponse ΒΆ added in v0.0.2

type TextToSpeechResponse struct {
	RequestId string
	Audios    []string
}

TextToSpeechResponse represents the result of a text-to-speech operation.

func TextToSpeech ΒΆ

func TextToSpeech(text string, targetLanguage Language, params TextToSpeechParams) (*TextToSpeechResponse, error)

TextToSpeech is a package-level function that uses the default client

func (*TextToSpeechResponse) Bytes ΒΆ added in v0.0.2

func (t *TextToSpeechResponse) Bytes() ([]byte, error)

func (*TextToSpeechResponse) Save ΒΆ added in v0.0.2

func (t *TextToSpeechResponse) Save(filename string) error

Save saves the text-to-speech data as a WAV file.

type Timestamps ΒΆ

type Timestamps struct {
	Words            []string  `json:"words"`
	StartTimeSeconds []float64 `json:"start_time_seconds"`
	EndTimeSeconds   []float64 `json:"end_time_seconds"`
}

Timestamps represents word-level timing information for speech-to-text results.

type TranslateParams ΒΆ

type TranslateParams struct {
	SpeakerGender       *SpeakerGender
	Mode                *TranslationMode
	Model               *TranslationModel
	EnablePreprocessing *bool
	OutputScript        *OutputScript
	NumeralsFormat      *NumeralsFormat
}

TranslateParams contains all optional parameters for translation.

type TranslationMode ΒΆ

type TranslationMode string

TranslationMode specifies the tone or style of the translation.

const (
	// TranslationModeFormal represents formal translation style.
	TranslationModeFormal TranslationMode = "formal"
	// TranslationModeModernColloquial represents modern colloquial translation style.
	TranslationModeModernColloquial TranslationMode = "modern-colloquial"
	// TranslationModeClassicColloquial represents classic colloquial translation style.
	TranslationModeClassicColloquial TranslationMode = "classic-colloquial"
	// TranslationModeCodeMixed represents code-mixed translation style.
	TranslationModeCodeMixed TranslationMode = "code-mixed"
)

type TranslationModel ΒΆ

type TranslationModel string

TranslationModel specifies the translation model to use.

var (
	TranslationModelMayuraV1        TranslationModel = "mayura:v1"
	TranslationModelSarvamTranslate TranslationModel = "sarvam-translate:v1"
)

type TranslationResponse ΒΆ added in v0.0.2

type TranslationResponse struct {
	RequestId      string
	TranslatedText string
	SourceLanguage Language
}

TranslationResponse represents the result of a translation operation.

func Translate ΒΆ added in v0.0.2

func Translate(input string, sourceLanguageCode, targetLanguageCode Language, params *TranslateParams) (*TranslationResponse, error)

Translate is a package-level function that uses the default client

func (*TranslationResponse) String ΒΆ added in v0.0.2

func (t *TranslationResponse) String() string

String returns the translated text.

type TransliterateParams ΒΆ added in v0.0.2

type TransliterateParams struct {
	NumeralsFormat             *NumeralsFormat
	SpokenFormNumeralsLanguage *SpokenFormNumeralsLanguage
	SpokenForm                 *bool
}

TransliterateParams contains all optional parameters for transliteration.

type TransliterationResponse ΒΆ added in v0.0.2

type TransliterationResponse struct {
	RequestId          string
	TransliteratedText string
	SourceLanguage     Language
}

TransliterationResponse represents the result of a transliteration operation.

func Transliterate ΒΆ added in v0.0.2

func Transliterate(input string, sourceLanguage Language, targetLanguage Language) (*TransliterationResponse, error)

Transliterate is a package-level function that uses the default client

func (*TransliterationResponse) String ΒΆ added in v0.0.2

func (t *TransliterationResponse) String() string

String returns the transliterated text.

type Usage ΒΆ

type Usage struct {
	CompletionTokens int `json:"completion_tokens"`
	PromptTokens     int `json:"prompt_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage represents token usage information for the API call.

Directories ΒΆ

Path Synopsis
examples
chatcompletions command
speechtotext command
text command
texttospeech command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL