> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# FastPix Go SDK

The FastPix Go SDK is a strongly typed Go client for the FastPix video API. From any Go application you can upload and manage videos, run live streams and simulcasts, create and secure playback IDs, manage playlists and signing keys, pull video analytics, and use in-video AI features.

\


> **Find more in the SDK reference**
>
> For all methods, runnable examples, and advanced usage, see the [FastPix Go SDK](https://github.com/FastPix/fastpix-go) on GitHub.

\


## Before you begin

Make sure you have:

* Go 1.21 or later
* Go Modules enabled
* Internet access
* A FastPix account
* A FastPix Access Token and Secret Key, generated from the [FastPix Dashboard](https://dashboard.fastpix.com). See [Activate your account](/getting-started/activate-your-account).

FastPix uses HTTP Basic Authentication. The SDK maps your credentials as follows:

| SDK value  | FastPix credential |
| ---------- | ------------------ |
| `Username` | Access Token       |
| `Password` | Secret Key         |

> **Security:** Never commit your Access Token or Secret Key to source control. Use environment variables or a secure credential-management system.

Follow the steps below in order, and do not skip the verification steps. If installation, import, authentication, client initialization, or the first API request fails, fix that problem before continuing.

\


## Check your Go version

```bash
go version
```

The output is similar to `go version go1.21.0 darwin/arm64` or a later version. The SDK supports Go 1.21 and later. If your version is earlier than 1.21, install a supported version before continuing.

\


## Create a Go project

Create a directory for your application and initialize a Go module:

```bash
mkdir fastpix-go-demo
cd fastpix-go-demo
go mod init fastpix-go-demo
```

`go mod init` creates a `go.mod` file that tracks your module name and dependencies.

\


## Install the FastPix SDK

Install the FastPix Go SDK with Go Modules:

```bash
go get github.com/FastPix/fastpix-go
```

Go downloads the SDK and adds it to your dependencies. Confirm the dependency:

```bash
go list -m github.com/FastPix/fastpix-go
```

The output lists the module and the installed version.

\


## Verify the SDK installation

Confirm that your Go project can import the SDK. Create a file named `main.go`:

```go
package main

import (
	"fmt"

	fastpixgo "github.com/FastPix/fastpix-go"
)

func main() {
	_ = fastpixgo.New
	fmt.Println("FastPix SDK imported successfully")
}
```

Run it:

```bash
go run .
```

The expected output is `FastPix SDK imported successfully`. If it fails, confirm that Go 1.21 or later is installed, the module is initialized, `github.com/FastPix/fastpix-go` is listed in `go.mod`, and you are running the command from the project directory. If needed, run `go mod tidy` and try again.

\


## Configure authentication

FastPix uses HTTP Basic Authentication, where `Username` is your Access Token and `Password` is your Secret Key. For local development, set these as environment variables so they stay out of your source code:

```bash
# macOS and Linux
export FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
export FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"
```

```powershell
# Windows PowerShell
$env:FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
$env:FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"
```

\


## Verify that your credentials are set

Check that both variables are set without printing their values:

```bash
# macOS and Linux
if [ -n "$FASTPIX_USERNAME" ]; then echo "Access Token: set"; else echo "Access Token: missing"; fi
if [ -n "$FASTPIX_PASSWORD" ]; then echo "Secret Key: set"; else echo "Secret Key: missing"; fi
```

Both should report `set`. If either is `missing`, set the corresponding environment variable before continuing.

\


## Initialize the FastPix client

Replace `main.go` with:

```go
package main

import (
	"context"
	"fmt"
	"os"

	fastpixgo "github.com/FastPix/fastpix-go"
	"github.com/FastPix/fastpix-go/models/components"
)

func main() {
	ctx := context.Background()

	fastpix := fastpixgo.New(
		fastpixgo.WithSecurity(components.Security{
			Username: fastpixgo.Pointer(os.Getenv("FASTPIX_USERNAME")),
			Password: fastpixgo.Pointer(os.Getenv("FASTPIX_PASSWORD")),
		}),
	)

	_ = ctx
	_ = fastpix

	fmt.Println("FastPix client initialized")
}
```

Run it:

```bash
go run .
```

The expected output is `FastPix client initialized`. Initializing the client does not make an API request; a request happens only when you call an operation such as `fastpix.InputVideo.Create(...)`.

\


## Make your first API request

The easiest way to verify the integration is to create media from a publicly accessible video URL. FastPix provides a sample video at `https://static.fastpix.com/fp-sample-video.mp4`.

Replace `main.go` with:

```go
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	fastpixgo "github.com/FastPix/fastpix-go"
	"github.com/FastPix/fastpix-go/models/components"
)

func main() {
	ctx := context.Background()

	fastpix := fastpixgo.New(
		fastpixgo.WithSecurity(components.Security{
			Username: fastpixgo.Pointer(os.Getenv("FASTPIX_USERNAME")),
			Password: fastpixgo.Pointer(os.Getenv("FASTPIX_PASSWORD")),
		}),
	)

	response, err := fastpix.InputVideo.Create(
		ctx,
		components.CreateMediaRequest{
			Inputs: []components.Input{
				components.CreateInputPullVideoInput(
					components.PullVideoInput{
						URL: fastpixgo.Pointer(
							"https://static.fastpix.com/fp-sample-video.mp4",
						),
					},
				),
			},
			Metadata: map[string]string{
				"source": "fastpix-go-demo",
			},
		},
	)
	if err != nil {
		log.Fatal(err)
	}

	if response.CreateMediaSuccessResponse == nil {
		log.Fatal("FastPix API did not return a successful media response")
	}

	output, err := json.MarshalIndent(
		response.CreateMediaSuccessResponse,
		"",
		"  ",
	)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(string(output))
}
```

Run it:

```bash
go run .
```

A successful request returns information about the newly created media asset, similar to:

```json
{
  "success": true,
  "data": {
    "id": "..."
  }
}
```

The exact fields depend on the API response and the installed SDK version. A `media_id` is not the same as a `playback_id`. They identify different resources and are used for different operations.

\


## Retrieve the media asset

Use the media ID returned by the create operation to retrieve the media asset. The Go SDK exposes this through `fastpix.Videos.Get(ctx, mediaID)`. Replace `main.go` with:

```go
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	fastpixgo "github.com/FastPix/fastpix-go"
	"github.com/FastPix/fastpix-go/models/components"
)

func main() {
	ctx := context.Background()

	fastpix := fastpixgo.New(
		fastpixgo.WithSecurity(components.Security{
			Username: fastpixgo.Pointer(os.Getenv("FASTPIX_USERNAME")),
			Password: fastpixgo.Pointer(os.Getenv("FASTPIX_PASSWORD")),
		}),
	)

	// Create media.
	fmt.Println("Creating media...")
	createResponse, err := fastpix.InputVideo.Create(
		ctx,
		components.CreateMediaRequest{
			Inputs: []components.Input{
				components.CreateInputPullVideoInput(
					components.PullVideoInput{
						URL: fastpixgo.Pointer(
							"https://static.fastpix.com/fp-sample-video.mp4",
						),
					},
				),
			},
			Metadata: map[string]string{
				"source": "fastpix-go-demo",
			},
		},
	)
	if err != nil {
		log.Fatal(err)
	}

	if createResponse.CreateMediaSuccessResponse == nil {
		log.Fatal("FastPix API did not return a successful media response")
	}

	createData := createResponse.CreateMediaSuccessResponse

	output, err := json.MarshalIndent(createData, "", "  ")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("\nCREATE MEDIA")
	fmt.Println(string(output))

	// Carry the media ID from create into the next call.
	mediaID := createData.Data.Id
	fmt.Println("\nMEDIA ID:")
	fmt.Println(mediaID)

	// Retrieve the media.
	fmt.Println("\nRetrieving media...")
	mediaResponse, err := fastpix.Videos.Get(ctx, mediaID)
	if err != nil {
		log.Fatal(err)
	}

	if mediaResponse.Object == nil {
		log.Fatal("FastPix API did not return media data")
	}

	mediaOutput, err := json.MarshalIndent(
		mediaResponse.Object,
		"",
		"  ",
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("\nGET MEDIA")
	fmt.Println(string(mediaOutput))
}
```

Run it:

```bash
go run .
```

A successful response from the get-media operation confirms that the SDK authenticated, the media was created, a media ID was returned, and the media ID can be used in a subsequent API operation.

\


## Verify the integration

A successful create-then-get flow confirms that Go is installed and supported, Go Modules are configured, the SDK is installed and importable, your credentials are configured, the client can authenticate, and you can create and retrieve a media asset.

Creating media is usually the first step in a FastPix on-demand workflow: you create the media, poll it until processing finishes, then create a playback ID to play it. The initial SDK integration is now complete.

\


## Resources, error handling, and reference

The SDK is generated from the FastPix API specification, so the complete and always-current reference lives in the repo and the API docs:

* **All resources, operations, error handling, retries, server selection, and custom HTTP clients**: the [FastPix Go SDK on GitHub](https://github.com/FastPix/fastpix-go), with runnable code in the [examples](https://github.com/FastPix/fastpix-go/tree/main/examples) directory.
* **Media** (upload, manage, playback, playlists, signing keys, DRM): [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).
* **Live** (streams, simulcasts, live playback): [Live Stream API](https://fastpix.com/docs/live-stream-api/overview).
* **Video Data** (metrics, views, dimensions, errors): [Video Data API](https://fastpix.com/docs/video-data-api/overview).
* **In-video AI** (summaries, chapters, named entities, moderation): [In-Video AI](/in-video-ai/overview).

\


#### Frequently asked questions

The SDK is a strongly typed Go wrapper around the same FastPix REST API. It handles authentication, request serialization, and response parsing for you, so you call methods like `fastpix.InputVideo.Create(...)` instead of building raw HTTP requests. Anything the SDK does, you can also do by calling the REST API directly. See [Make your first API request](#make-your-first-api-request).

Run `go get github.com/FastPix/fastpix-go` and import it in your module. See [Install the FastPix SDK](#install-the-fastpix-sdk).

FastPix uses HTTP Basic Authentication. Build the client with `components.Security`, passing your Access Token as `Username` and your Secret Key as `Password`. See [Initialize the FastPix client](#initialize-the-fastpix-client).

Create media from a URL or a direct upload through the input-video resource on the client, for example `fastpix.InputVideo.Create(ctx, ...)`. See [Make your first API request](#make-your-first-api-request).

FastPix uploads are not limited by your Go process memory. When you pull from a URL, FastPix fetches the file directly, and when you upload from a device, the SDK gives you a signed URL that the file goes to directly, so the bytes never pass through your Go application. Large multi-gigabyte files upload without extra configuration. See the [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).

Use the Live API resources to create and manage streams, simulcasts, and live playback IDs. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-go) and the [Live Stream API](https://fastpix.com/docs/live-stream-api/overview).

Generate playback IDs and manage signing keys and DRM configurations through the Media API resources. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-go) and the [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).

Create the media with a private access policy, then generate a signed playback ID so only holders of a valid token can play it. For stronger protection, enable DRM on the playback ID. You revoke access by deleting the playback ID. Handle all of this through the Media API resources. See the [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).

The Video Data API exposes metrics, views, dimensions, and errors for quality-of-experience monitoring. See the [Video Data API](https://fastpix.com/docs/video-data-api/overview).

API errors are returned as `apierrors.APIError`. Use `errors.As` to inspect the status code and body. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-go) for the error types each operation can return.

Pass `operations.WithRetries(...)` per call, or `fastpixgo.WithRetryConfig(...)` at initialization, to control the backoff strategy. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-go).

Provide any client that satisfies the SDK's `HTTPClient` interface (for example an `*http.Client` with a timeout) through `fastpixgo.WithClient(...)`. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-go).

Use `fastpixgo.WithServerURL(...)` when constructing the client. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-go).

Go 1.21 and later. See [Before you begin](#before-you-begin).

\


## What's next

Want to go further? Browse runnable, end-to-end samples for the FastPix Go SDK in the [examples folder](https://github.com/FastPix/fastpix-go/tree/main/examples) of the GitHub repository.

\


## Release notes

For a complete history of releases, improvements, and fixes, see the [FastPix Go SDK CHANGELOG on GitHub](https://github.com/FastPix/fastpix-go/blob/main/CHANGELOG.md).