Design & media

go-elevenlabs

Try it

Unofficial Go client for the ElevenLabs REST API, generated with oapi-codegen. `elevenlabs.NewClientWithResponses("https://api.elevenlabs.io", opts...)` from `github.com/psyb0t/go-elevenlabs` returns a `*elevenlabs.ClientWithResponses` with one typed `...WithResponse` method per endpoint (voices, text to speech, speech to text, sound effects, dubbing, user info and more). Auth is the `xi-api-key` header set through `elevenlabs.WithRequestEditorFn`; JSON replies decode into `JSON200`, and audio replies come back as raw bytes in `Body`. Use when Go code needs to call ElevenLabs or already imports go-elevenlabs.

What it does

Typed Go client for the ElevenLabs API. Every endpoint in the ElevenLabs OpenAPI document is a method on .

The skill document

go-elevenlabs

Typed Go client for the ElevenLabs API. Every endpoint in the ElevenLabs OpenAPI document is a method on ClientWithResponses.

For install, client options, more operations and response handling, see references/setup.md.

Security & safety

  • Read the API key from an environment variable such as ELEVENLABS_API_KEY. Never hardcode it, commit it or log it, and never print request headers.
  • Requests go only to the base URL you pass, https://api.elevenlabs.io. Text, audio and voice samples you send are processed by ElevenLabs.
  • Generation endpoints use account credits, and voice cloning and delete endpoints change the account. Call them only when the user asked for that action, and clone only voices the user has the rights to.

When to use

  • Go code needs to list voices, turn text into speech, transcribe audio or call another ElevenLabs endpoint.
  • The project already imports github.com/psyb0t/go-elevenlabs.

When NOT to use

  • You need the realtime WebSocket APIs. This client covers only the REST API.
  • The code is not Go.

Usage

import (
	"context"
	"fmt"
	"net/http"
	"os"

	"github.com/psyb0t/go-elevenlabs"
)

auth := elevenlabs.WithRequestEditorFn(
	func(_ context.Context, req *http.Request) error {
		req.Header.Set("xi-api-key", os.Getenv("ELEVENLABS_API_KEY"))

		return nil
	},
)

client, err := elevenlabs.NewClientWithResponses(
	"https://api.elevenlabs.io",
	auth,
)
if err != nil {
	return err
}

voices, err := client.GetVoicesWithResponse(ctx, nil)
if err != nil {
	return err // transport failure
}

if voices.JSON200 == nil {
	return fmt.Errorf("elevenlabs: status %d", voices.StatusCode())
}

for _, voice := range voices.JSON200.Voices {
	fmt.Println(voice.VoiceId, voice.Name)
}

Text to speech. A 200 reply is audio, so read Body:

speech, err := client.TextToSpeechFullWithResponse(
	ctx,
	voiceID,
	nil,
	elevenlabs.TextToSpeechFullJSONRequestBody{Text: "Hello there."},
)
if err != nil {
	return err
}

if speech.StatusCode() != http.StatusOK {
	return fmt.Errorf("elevenlabs: status %d", speech.StatusCode())
}

audio := speech.Body // encoded per params.OutputFormat, e.g. mp3_44100_128

Leave the XiApiKey field of every ...Params struct nil and let the request editor set the header.

A method returns an error only when the request could not be sent or the body could not be decoded. An API error is a normal response: check StatusCode(); a 422 also fills JSON422, an *HTTPValidationError.

Related skills

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván561 installs18 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván857 installs69 stars

More from psyb0t

Browse all skills

Drive a user-deployed mt5-httpapi MetaTrader 5 bridge over HTTP, with per-action confirmation on every real-money call.

by psyb0t108 installs4 stars

Docker-packaged browser automation for QA against anti-bot stacks and authorized detection testing.

by psyb0t138 installs2 stars

Self-hosted OpenAI-compatible speech service — transcription, translation, and synthesis from one container.

by psyb0t13 installs

Run ffmpeg, sox, and ImageMagick jobs against your files in a fixed-allowlist SSH sandbox.

by psyb0t71 installs

Generate speech audio via Qwen3-TTS over SSH with preset voices, voice cloning, and voice design.

by psyb0t55 installs

Drive one or more IMAP/SMTP mailboxes through a single REST + MCP endpoint — read, search, send, mark-seen, and delete across accounts in parallel.

by psyb0t15 installs