Documentation
¶
Overview ¶
Package ambie is the official Go SDK for AMBIE.
See https://ambie.ai/sdk for the full API reference.
Index ¶
- Constants
- func VerifyWebhookSignature(opts VerifyWebhookOptions) error
- type ActionItem
- type AsyncAccepted
- type Chapter
- type Client
- func (c *Client) DetectLanguage(ctx context.Context, opts DetectLangOptions) (*DetectLangResult, error)
- func (c *Client) Embeddings(ctx context.Context, opts EmbeddingsOptions) (*EmbeddingsResult, error)
- func (c *Client) GetTranscribeJob(ctx context.Context, requestID string) (*JobStatus, error)
- func (c *Client) GetTranslateJob(ctx context.Context, requestID string) (*JobStatus, error)
- func (c *Client) GetTtsJob(ctx context.Context, requestID string) (*JobStatus, error)
- func (c *Client) Moderate(ctx context.Context, opts ModerateOptions) (*ModerateResult, error)
- func (c *Client) Rerank(ctx context.Context, opts RerankOptions) (*RerankResult, error)
- func (c *Client) Sentiment(ctx context.Context, opts SentimentOptions) (*SentimentResult, error)
- func (c *Client) Summarize(ctx context.Context, opts SummarizeOptions) (*SummarizeResult, error)
- func (c *Client) TTS(ctx context.Context, opts TtsOptions) (*TtsResult, error)
- func (c *Client) Transcribe(ctx context.Context, opts TranscribeOptions) (*TranscriptionResult, error)
- func (c *Client) TranscribeAsync(ctx context.Context, opts TranscribeOptions) (*AsyncAccepted, error)
- func (c *Client) Translate(ctx context.Context, opts TranslateOptions) (*TranslationResult, error)
- type DetectLangAlternative
- type DetectLangOptions
- type DetectLangResult
- type EmbeddingsOptions
- type EmbeddingsResult
- type Error
- type JobStatus
- type ModerateOptions
- type ModerateResult
- type Option
- type RerankItem
- type RerankOptions
- type RerankResult
- type SentimentItem
- type SentimentOptions
- type SentimentResult
- type SummarizeOptions
- type SummarizeResult
- type TranscribeOptions
- type TranscriptionResult
- type TranslateOptions
- type TranslationResult
- type TtsOptions
- type TtsResult
- type Utterance
- type VerifyWebhookOptions
- type Word
Constants ¶
const DefaultToleranceSeconds = 300
DefaultToleranceSeconds is the default maximum age for a webhook signature.
Variables ¶
This section is empty.
Functions ¶
func VerifyWebhookSignature ¶
func VerifyWebhookSignature(opts VerifyWebhookOptions) error
VerifyWebhookSignature verifies a Stripe-compatible webhook signature of the form "t=<unix_ts>,v1=<hex>". It recomputes HMAC-SHA256 of "{t}.{body}" with the secret and compares in constant time.
Types ¶
type ActionItem ¶
type AsyncAccepted ¶
type AsyncAccepted struct {
RequestID string `json:"request_id"`
PollURL string `json:"poll_url"`
Status string `json:"status"`
ClientID string `json:"client_id,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
}
AsyncAccepted is the response when a callback_url is provided.
type Client ¶
type Client struct {
APIKey string
BaseURL string
HTTPClient *http.Client
MaxRetries int
UserAgent string
}
Client is the AMBIE API client.
func (*Client) DetectLanguage ¶
func (c *Client) DetectLanguage(ctx context.Context, opts DetectLangOptions) (*DetectLangResult, error)
func (*Client) Embeddings ¶
func (c *Client) Embeddings(ctx context.Context, opts EmbeddingsOptions) (*EmbeddingsResult, error)
func (*Client) GetTranscribeJob ¶
GetTranscribeJob polls a transcription job by request_id.
func (*Client) GetTranslateJob ¶
func (*Client) Moderate ¶
func (c *Client) Moderate(ctx context.Context, opts ModerateOptions) (*ModerateResult, error)
func (*Client) Rerank ¶
func (c *Client) Rerank(ctx context.Context, opts RerankOptions) (*RerankResult, error)
func (*Client) Sentiment ¶
func (c *Client) Sentiment(ctx context.Context, opts SentimentOptions) (*SentimentResult, error)
func (*Client) Summarize ¶
func (c *Client) Summarize(ctx context.Context, opts SummarizeOptions) (*SummarizeResult, error)
func (*Client) Transcribe ¶
func (c *Client) Transcribe(ctx context.Context, opts TranscribeOptions) (*TranscriptionResult, error)
Transcribe uploads an audio file (or fetches a URL) and returns the result. If opts.CallbackURL is set the API returns 202 and you should consume the AsyncAccepted struct (use TranscribeAsync). Use this method only for sync.
func (*Client) TranscribeAsync ¶
func (c *Client) TranscribeAsync(ctx context.Context, opts TranscribeOptions) (*AsyncAccepted, error)
TranscribeAsync submits a transcribe request with a callback URL and returns the AsyncAccepted handle. opts.CallbackURL must be set.
func (*Client) Translate ¶
func (c *Client) Translate(ctx context.Context, opts TranslateOptions) (*TranslationResult, error)
type DetectLangAlternative ¶
type DetectLangOptions ¶
type DetectLangResult ¶
type DetectLangResult struct {
RequestID string `json:"request_id"`
ClientID string `json:"client_id,omitempty"`
Language string `json:"language"`
Confidence float64 `json:"confidence"`
Alternatives []DetectLangAlternative `json:"alternatives,omitempty"`
}
type EmbeddingsOptions ¶
type EmbeddingsResult ¶
type Error ¶
type Error struct {
Status int `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
RequestID string `json:"request_id,omitempty"`
}
Error is returned for any non-2xx API response after retries.
type JobStatus ¶
type JobStatus struct {
RequestID string `json:"request_id"`
Status string `json:"status"`
ClientID string `json:"client_id,omitempty"`
Result map[string]any `json:"result,omitempty"`
Error string `json:"error,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
CompletedAt string `json:"completed_at,omitempty"`
}
JobStatus is the response from a status polling endpoint.
type ModerateOptions ¶
type ModerateResult ¶
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient injects a custom HTTP client.
func WithMaxRetries ¶
WithMaxRetries sets retry attempts on 429/5xx (default 3).
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header.
type RerankItem ¶
type RerankOptions ¶
type RerankResult ¶
type RerankResult struct {
RequestID string `json:"request_id"`
ClientID string `json:"client_id,omitempty"`
Results []RerankItem `json:"results"`
}
type SentimentItem ¶
type SentimentOptions ¶
type SentimentResult ¶
type SentimentResult struct {
RequestID string `json:"request_id"`
ClientID string `json:"client_id,omitempty"`
Results []SentimentItem `json:"results"`
}
type SummarizeOptions ¶
type SummarizeResult ¶
type TranscribeOptions ¶
type TranscribeOptions struct {
Audio []byte
AudioName string // optional; defaults to "audio.bin"
URL string
Engine string // "deepgram" (default) or "whisper"
Language string
Format string // "json" (default), "text", "srt", "vtt"
Translate bool
CallbackURL string
ClientID string
Diarize bool
Summarize bool
KeyPhrases bool
ActionItems bool
Chapters bool
// Extra holds any other fields documented in openapi.yaml
// (punctuate, smart_format, multichannel, vocabulary, etc.).
Extra map[string]string
}
TranscribeOptions configures a transcription request. Either Audio or URL is required. Audio takes a filename and the raw bytes.
type TranscriptionResult ¶
type TranscriptionResult struct {
RequestID string `json:"request_id"`
ClientID string `json:"client_id,omitempty"`
Engine string `json:"engine"`
Language string `json:"language,omitempty"`
Duration float64 `json:"duration"`
Text string `json:"text"`
Confidence float64 `json:"confidence,omitempty"`
Words []Word `json:"words,omitempty"`
Utterances []Utterance `json:"utterances,omitempty"`
DiarizedText string `json:"diarized_text,omitempty"`
SpeakerCount int `json:"speaker_count,omitempty"`
Paragraphs []string `json:"paragraphs,omitempty"`
Summary string `json:"summary,omitempty"`
KeyPhrases []string `json:"key_phrases,omitempty"`
ActionItems []ActionItem `json:"action_items,omitempty"`
Chapters []Chapter `json:"chapters,omitempty"`
}
type TranslateOptions ¶
type TranslateOptions struct {
Text string `json:"text"`
TargetLang string `json:"target_lang"`
SourceLang string `json:"source_lang,omitempty"`
Formality string `json:"formality,omitempty"`
Context string `json:"context,omitempty"`
CallbackURL string `json:"callback_url,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
type TranslationResult ¶
type TranslationResult struct {
RequestID string `json:"request_id"`
ClientID string `json:"client_id,omitempty"`
SourceLang string `json:"source_lang"`
TargetLang string `json:"target_lang"`
SourceText string `json:"source_text"`
TranslatedText string `json:"translated_text"`
Confidence float64 `json:"confidence,omitempty"`
}
type TtsOptions ¶
type TtsOptions struct {
Text string `json:"text"`
Voice string `json:"voice,omitempty"`
Engine string `json:"engine,omitempty"`
Language string `json:"language,omitempty"`
Encoding string `json:"encoding,omitempty"`
Container string `json:"container,omitempty"`
Speed float64 `json:"speed,omitempty"`
CallbackURL string `json:"callback_url,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
type VerifyWebhookOptions ¶
type VerifyWebhookOptions struct {
Signature string // X-Ambie-Signature header value
Body []byte // raw request body bytes (NOT parsed JSON)
Secret string // webhook secret from /signup
ToleranceSeconds int // 0 = use default (300)
NowFunc func() int64
}
VerifyWebhookOptions configures VerifyWebhookSignature.