https://github.com/assemblyai/assemblyai-go-sdk
Official Go SDK
https://github.com/assemblyai/assemblyai-go-sdk
Last synced: 10 months ago
JSON representation
Official Go SDK
- Host: GitHub
- URL: https://github.com/assemblyai/assemblyai-go-sdk
- Owner: AssemblyAI
- License: mit
- Created: 2023-10-31T14:41:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-16T09:48:42.000Z (about 2 years ago)
- Last Synced: 2024-05-02T01:47:28.306Z (almost 2 years ago)
- Language: Go
- Homepage:
- Size: 5.08 MB
- Stars: 10
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

---
[](https://github.com/AssemblyAI/assemblyai-go-sdk/actions/workflows/go.yml)
[](https://github.com/AssemblyAI/assemblyai-go-sdk/blob/main/LICENSE)
[](https://pkg.go.dev/github.com/AssemblyAI/assemblyai-go-sdk)
[](https://twitter.com/AssemblyAI)
[](https://www.youtube.com/@AssemblyAI)
[
](https://assemblyai.com/discord)
# AssemblyAI Go SDK
> [!IMPORTANT]
> As of April 2025, AssemblyAI Go SDK **has been discontinued** and will no longer be maintained.
>
> While the SDK will no longer be updated, any previously published releases will remain available.
>
> Going forward, see the [AssemblyAI API reference](https://www.assemblyai.com/docs/api-reference) for information on how to integrate with our API directly.
>
> We know this is a disruptive change. If you need help with this transition, [reach out to our Support team](https://www.assemblyai.com/contact/support) and we'll help you in any way we can.
A Go client library for accessing [AssemblyAI](https://assemblyai.com).
## Overview
- [AssemblyAI Go SDK](#assemblyai-go-sdk)
- [Overview](#overview)
- [Documentation](#documentation)
- [Quickstart](#quickstart)
- [Installation](#installation)
- [Examples](#examples)
- [Core Transcription](#core-transcription)
- [Audio Intelligence](#audio-intelligence)
- [Real-Time Transcription](#real-time-transcription)
- [Playgrounds](#playgrounds)
- [Tips and tricks](#tips-and-tricks)
- [Inspect API errors](#inspect-api-errors)
## Documentation
Visit our [AssemblyAI API Documentation](https://www.assemblyai.com/docs) to get an overview of our models!
See the reference docs at [pkg.go.dev](https://pkg.go.dev/github.com/AssemblyAI/assemblyai-go-sdk).
## Quickstart
### Installation
```bash
go get github.com/AssemblyAI/assemblyai-go-sdk
```
### Examples
Before you begin, you need to have your API key. If you don't have one yet, [**sign up for one**](https://www.assemblyai.com/dashboard/signup)!
#### Core Transcription
Transcribe an audio file from URL
```go
package main
import (
"context"
"log"
"os"
"github.com/AssemblyAI/assemblyai-go-sdk"
)
func main() {
apiKey := os.Getenv("ASSEMBLYAI_API_KEY")
ctx := context.Background()
audioURL := "https://example.org/audio.mp3"
client := assemblyai.NewClient(apiKey)
transcript, err := client.Transcripts.TranscribeFromURL(ctx, audioURL, nil)
if err != nil {
log.Fatal("Something bad happened:", err)
}
log.Println(*transcript.Text)
}
```
Transcribe a local audio file
```go
package main
import (
"context"
"log"
"os"
"github.com/AssemblyAI/assemblyai-go-sdk"
)
func main() {
apiKey := os.Getenv("ASSEMBLYAI_API_KEY")
ctx := context.Background()
client := assemblyai.NewClient(apiKey)
f, err := os.Open("./my-local-audio-file.wav")
if err != nil {
log.Fatal("Couldn't open audio file:", err)
}
defer f.Close()
transcript, err := client.Transcripts.TranscribeFromReader(ctx, f, nil)
if err != nil {
log.Fatal("Something bad happened:", err)
}
log.Println(*transcript.Text)
}
```
#### Audio Intelligence
Identify entities in a transcript
```go
package main
import (
"context"
"log"
"os"
"github.com/AssemblyAI/assemblyai-go-sdk"
)
func main() {
apiKey := os.Getenv("ASSEMBLYAI_API_KEY")
ctx := context.Background()
audioURL := "https://example.org/audio.mp3"
client := assemblyai.NewClient(apiKey)
opts := &assemblyai.TranscriptParams{
EntityDetection: assemblyai.Bool(true),
}
transcript, err := client.Transcripts.TranscribeFromURL(ctx, audioURL, opts)
if err != nil {
log.Fatal("Something bad happened:", err)
}
for _, entity := range transcript.Entities {
log.Println(*entity.Text)
log.Println(entity.EntityType)
log.Printf("Timestamp: %v - %v", *entity.Start, *entity.End)
}
}
```
#### Real-Time Transcription
Check out the [realtime](./examples/realtime) example.
## Playgrounds
Visit one of our Playgrounds:
- [LeMUR Playground](https://www.assemblyai.com/playground/v2/source)
- [Transcription Playground](https://www.assemblyai.com/playground)
## Tips and tricks
### Inspect API errors
If you receive an API error, you can inspect the HTTP response returned by the API for more details:
```go
transcript, err := client.Transcripts.TranscribeFromURL(ctx, audioURL, nil)
if err != nil {
var apierr aai.APIError
if errors.As(err, &apierr) {
// apierr.Response is the *http.Response from the API call.
fmt.Println(apierr.Response.StatusCode)
} else {
// err is not an API error.
}
}
```