{"id":23817847,"url":"https://github.com/lsongdev/openai-go","last_synced_at":"2026-05-06T09:30:17.896Z","repository":{"id":68774020,"uuid":"574880455","full_name":"lsongdev/openai-go","owner":"lsongdev","description":"OpenAI Golang Library","archived":false,"fork":false,"pushed_at":"2023-09-01T07:32:23.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T22:23:46.581Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lsongdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-12-06T09:24:52.000Z","updated_at":"2023-03-04T11:36:41.000Z","dependencies_parsed_at":"2024-06-20T17:21:08.886Z","dependency_job_id":"cb52f12a-30e1-4f04-85e4-72198b9903e7","html_url":"https://github.com/lsongdev/openai-go","commit_stats":null,"previous_names":["lsongdev/openai-go"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fopenai-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fopenai-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fopenai-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fopenai-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsongdev","download_url":"https://codeload.github.com/lsongdev/openai-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240093155,"owners_count":19746780,"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":"2025-01-02T05:48:53.631Z","updated_at":"2026-05-06T09:30:17.847Z","avatar_url":"https://github.com/lsongdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openai.go\n\n\u003e OpenAI Library in Golang\n\n\n## Example\n\n### Completion API with GPT-3 Model\n\n```go\npackage main\n\nimport (\n    \"log\"\n\n\t\"github.com/song940/openai-go/openai\"\n)\n\nfunc main() {\n\tconfig := openai.Configuration{\n\t\tAPIKey: \"your api key\",\n\t}\n\tclient, err := openai.NewClient(config)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treq := openai.CompletionRequest{\n\t\tModel:     openai.GPT3TextDavinci003,\n\t\tMaxTokens: 2048,\n\t\tPrompt:    \"Say this is a test\",\n\t}\n\tresp, err := client.CreateCompletion(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.Println(resp.Choices[0].Text)\n}\n```\n\n### Chat API with ChatAGPT Model\n\n```go\npackage main\n\nimport (\n    \"log\"\n\n\t\"github.com/song940/openai-go/openai\"\n)\n\nfunc main() {\n\tconfig := openai.Configuration{\n\t\tAPIKey: \"your api key\",\n\t}\n\tclient, err := openai.NewClient(config)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tmessage := openai.ChatCompletionMessage{\n\t\tRole:    openai.RoleUser,\n\t\tContent: \"Hello!\",\n\t}\n\treq := openai.ChatCompletionRequest{\n\t\tModel:     \"gpt-3.5-turbo\",\n\t\tMaxTokens: 2048,\n\t\tMessages: []openai.ChatCompletionMessage{\n\t\t\tmessage,\n\t\t},\n\t}\n\tresp, err := client.CreateChatCompletion(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.Println(resp.Choices[0].Message.Role)\n\tlog.Println(resp.Choices[0].Message.Content)\n}\n```\n\n## License\n\nThis Project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fopenai-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsongdev%2Fopenai-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fopenai-go/lists"}