{"id":19815943,"url":"https://github.com/replicate/replicate-go","last_synced_at":"2025-10-30T02:58:37.812Z","repository":{"id":181209354,"uuid":"644375315","full_name":"replicate/replicate-go","owner":"replicate","description":"Go client for Replicate","archived":false,"fork":false,"pushed_at":"2024-10-11T14:57:51.000Z","size":213,"stargazers_count":90,"open_issues_count":2,"forks_count":14,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-03-29T20:02:59.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://replicate.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replicate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T11:42:44.000Z","updated_at":"2025-03-07T15:24:12.000Z","dependencies_parsed_at":"2024-02-07T22:44:09.895Z","dependency_job_id":"231c9dd0-36e1-43c7-a2be-899fc861734e","html_url":"https://github.com/replicate/replicate-go","commit_stats":null,"previous_names":["replicate/replicate-go"],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Freplicate-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Freplicate-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Freplicate-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicate%2Freplicate-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replicate","download_url":"https://codeload.github.com/replicate/replicate-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399871,"owners_count":20932876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T10:07:49.359Z","updated_at":"2025-10-30T02:58:32.772Z","avatar_url":"https://github.com/replicate.png","language":"Go","funding_links":[],"categories":["API SDKs"],"sub_categories":[],"readme":"# Replicate Go client\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/replicate/replicate-go.svg)](https://pkg.go.dev/github.com/replicate/replicate-go)\n\nA Go client for [Replicate](https://replicate.com).\nIt lets you run models from your Go code,\nand everything else you can do with\n[Replicate's HTTP API](https://replicate.com/docs/reference/http).\n\n## Requirements\n\n- Go 1.20+\n\n## Installation\n\nUse `go get` to install the Replicate package:\n\n```console\ngo get -u github.com/replicate/replicate-go\n```\n\nInclude the Replicate package in your project:\n\n```go\nimport \"github.com/replicate/replicate-go\"\n```\n\n## Usage\n\n### Create a client\n\n```go\nimport (\n\t\"context\"\n\t\"os\"\n\n\t\"github.com/replicate/replicate-go\"\n)\n\nctx := context.TODO()\n\n// You can also provide a token directly with \n// `replicate.NewClient(replicate.WithToken(\"r8_...\"))`\nr8, err := replicate.NewClient(replicate.WithTokenFromEnv())\nif err != nil {\n\t// handle error\n}\n```\n\n### Run a model\n\n```go\nmodel := \"stability-ai/sdxl\"\nversion := \"7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc\"\n\ninput := replicate.PredictionInput{\n\t\"prompt\": \"An astronaut riding a rainbow unicorn\",\n}\n\nwebhook := replicate.Webhook{\n\tURL:    \"https://example.com/webhook\",\n\tEvents: []replicate.WebhookEventType{\"start\", \"completed\"},\n}\n\n// Run a model by version and wait for its output\noutput, _ := r8.Run(ctx, fmt.Sprintf(\"%s:%s\", model, version), input, \u0026webhook)\n\n// Run a model and wait for its output\noutput, _ := r8.Run(ctx, model, input, \u0026webhook)\n```\n\nThe `Run` method is a convenience method that\ncreates a prediction, waits for it to finish, and returns the output.\nIf you want a reference to the prediction, you can call `CreatePrediction`,\ncall `Wait` on the prediction, and access its `Output` field.\n\n```go\nprediction, _ := r8.CreatePrediction(ctx, version, input, \u0026webhook, false)\n_ = r8.Wait(ctx, prediction) // Wait for the prediction to finish\n```\n\nSome models take file inputs.\nUse the `CreateFileFromPath`, `CreateFileFromBytes`, or `CreateFileFromBuffer` method\nto upload a file and pass it as a prediction input.\n\n```go\n// https://replicate.com/vaibhavs10/incredibly-fast-whisper\nversion := \"3ab86df6c8f54c11309d4d1f930ac292bad43ace52d10c80d87eb258b3c9f79c\"\n\nfile, _ := r8.CreateFileFromPath(ctx, \"path/to/audio.mp3\", nil)\n\ninput := replicate.PredictionInput{\n\t\"audio\": file,\n}\nprediction, _ := r8.CreatePrediction(ctx, version, input, nil, false)\n```\n\n### Webhooks\n\nTo prevent unauthorized requests, Replicate signs every webhook and its metadata with a unique key for each user or organization. You can use this signature to verify the webhook indeed comes from Replicate before you process it.\n\nThis client includes a `ValidateWebhookRequest` convenience function that you can use to validate webhooks:\n\n```go\nimport (\n\t\"github.com/replicate/replicate-go\"\n)\n\nisValid, err := replicate.ValidateWebhookRequest(req, secret)\n```\n\nTo learn more, see the [webhooks guide](https://replicate.com/docs/webhooks).\n\n## License\n\nReplicate's Go client is released under the Apache 2.0 license.\nSee [LICENSE.txt](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplicate%2Freplicate-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplicate%2Freplicate-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplicate%2Freplicate-go/lists"}