Developer Guides9 min read

Go Speech-to-Text API: Transcribe Audio with the OpenAI Go SDK

Transcribe audio in Go using the OpenAI Go client with a Privocio base URL. Whisper-compatible batch transcription for backend services and AI agents.

Go developer workspace with terminal and code editor for speech-to-text API integration
Quick answer: In Go, point the official OpenAI client at Privocio by setting BaseURL to https://api.privocio.com/v1 and call audio.transcriptions with your API key — same Whisper-style flow as OpenAI, with predictable pricing and private infrastructure.

Go backends, microservices, and CLI tools often need speech-to-text without pulling in heavy ML runtimes. Privocio's Go speech-to-text API works through the OpenAI Go SDK with a one-line base URL change.

Also available: Python, JavaScript, and cURL guides.

Prerequisites

    • Go 1.21+
    • Privocio API key (authentication)
    • audio file, e.g. recording.wav

Install the OpenAI Go client:

go get github.com/openai/openai-go/v2

Go Speech-to-Text example

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/openai/openai-go/v2"
	"github.com/openai/openai-go/v2/option"
)

func main() {
	client := openai.NewClient(
		option.WithAPIKey(os.Getenv("PRIVOCIO_API_KEY")),
		option.WithBaseURL("https://api.privocio.com/v1"),
	)

	file, err := os.Open("recording.wav")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	resp, err := client.Audio.Transcriptions.New(context.Background(), openai.AudioTranscriptionNewParams{
		Model:    openai.AudioModelWhisper1,
		File:     file,
		Language: openai.String("en"),
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(resp.Text)
}

Run:

export PRIVOCIO_API_KEY="YOUR_API_KEY"
go run main.go

How it works

Base URL

option.WithBaseURL("https://api.privocio.com/v1") routes all SDK calls to Privocio instead of OpenAI — the main migration step. See migrate from OpenAI Whisper.

Model and file

whisper-1 and a readable os.File match the Whisper multipart contract documented in the API reference.

Context and errors

Always pass context.Context for timeouts in production services.

Production tips

    • Load PRIVOCIO_API_KEY from env or a secrets manager — never commit keys
    • Wrap the client in your own service layer for retries on 502 responses
    • Use output modes when feeding transcripts into LLM agents
    • Review rate limits and security controls

Raw HTTP alternative

Prefer no SDK? Use net/http with multipart form data or call from shell via cURL. The docs include copy-paste recipes.

Batch vs streaming

Privocio supports batch file transcription in Go via the SDK today. For live agents, consider streaming from a service that handles SSE, or use the JavaScript streaming guide pattern in a companion worker.

Frequently Asked Questions

Is the OpenAI Go SDK required?

No, but it is the fastest path if you already use OpenAI types. Raw HTTP works too.

Can I migrate from OpenAI Whisper?

Yes — change base URL and API key only. Compare Privocio vs OpenAI Whisper.

Does Privocio train on my audio?

Review our privacy policy and security page for data handling.

What about Python or Node?

See Python STT API and JavaScript STT API tutorials.

Conclusion

Go services get Whisper-compatible speech-to-text on Privocio with minimal code — set BaseURL, pass your key, and transcribe.

speech-to-textwhisper