{"id":24525625,"url":"https://github.com/aidenhadisi/chat-gpt-go","last_synced_at":"2026-05-16T11:34:26.281Z","repository":{"id":104249958,"uuid":"608951672","full_name":"AidenHadisi/chat-gpt-go","owner":"AidenHadisi","description":"Go API Client for OpenAI's GPT3.5 (ChatGPT) API.","archived":false,"fork":false,"pushed_at":"2023-03-03T15:37:04.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T05:20:23.105Z","etag":null,"topics":["ai","chatgpt","gpt-3","gpt35","openapi"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/AidenHadisi/chat-gpt-go","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AidenHadisi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-03-03T03:52:12.000Z","updated_at":"2023-03-16T12:55:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9321849-cf38-44c5-829b-44968e02ea7e","html_url":"https://github.com/AidenHadisi/chat-gpt-go","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidenHadisi%2Fchat-gpt-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidenHadisi%2Fchat-gpt-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidenHadisi%2Fchat-gpt-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidenHadisi%2Fchat-gpt-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AidenHadisi","download_url":"https://codeload.github.com/AidenHadisi/chat-gpt-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746241,"owners_count":20341204,"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":["ai","chatgpt","gpt-3","gpt35","openapi"],"created_at":"2025-01-22T05:19:27.353Z","updated_at":"2026-05-16T11:34:26.236Z","avatar_url":"https://github.com/AidenHadisi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChatGPT Go\n\nCommunicate with OpenAi's GPT3.5 (ChatGPT) API.\n\n## Usage\n    \n```go\n    package main\n\n    import chatgptgo \"github.com/AidenHadisi/chat-gpt-go\"\n\n    func main() {\n        api := chatgptgo.NewApi(\"YOUR_API_KEY\")\n\n        request := \u0026chatgptgo.Request{\n            Model: chatgptgo.Turbo,\n            Messages: []*chatgptgo.Message{\n                {\n                    Role:    \"user\",\n                    Content: \"Hello, world!\",\n                },\n            },\n        }\n\n        response, err := api.Chat(request)\n        if err != nil {\n            panic(err)\n        }\n\n        println(response.Choices[0].Message.Content)\n    }\n```\n\n## Additional Configuration\n\nFollowing configuration options are available in the `Request` struct:\n- `Model`: ID of the model to use. Currently, only `gpt-3.5-turbo` and `gpt-3.5-turbo-0301` are supported.\n- `Messages`: messages to generate chat completions for, in the chat format.\n- `Temperature`: what sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n- `TopP`: an alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.\n- `N`: how many chat completion choices to generate for each input message.\n- `Stop`: up to 4 sequences where the API will stop generating further tokens.\n- `MaxTokens`: maximum number of tokens to generate for each chat completion choice.\n- `PresencePenalty`: a number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n- `FrequencyPenalty`: a number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n- `User`: a unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.\n\n\n\n## Providing Organization ID\n\nYou may provide your OpenAI organization ID when creating the API instance.\n```go\n    api := chatgptgo.NewApi(\"YOUR_API_KEY\").WithOrganizationId(\"YOUR_ORGANIZATION_ID\")\n```\n\n\n## Using your own HTTP client\n\nYou may provide your own custom HTTP client when creating the API instance. (Uses `http.DefaultClient` if not provided).\n```go\n    api := chatgptgo.NewApi(\"YOUR_API_KEY\").WithClient(\u0026http.Client{Timeout: 10 * time.Second})\n```\n\n## Handling OpenAI API errors\n\nIf you need to get details about the error returned by the OpenAI API, you can try converting the error to `ApiError` type.\n```go\n    response, err := api.Chat(request)\n\tif err != nil {\n\t\tvar aerr *chatgptgo.ApiError\n\t\tif errors.As(err, \u0026aerr) {\n\t\t\t// handle OpenAI API errors\n\t\t\tfmt.Println(aerr.StatusCode)\n\t\t\tfmt.Println(aerr.ErrorDetails.Type)\n\t\t\tfmt.Println(aerr.ErrorDetails.Message)\n\t\t} else {\n\t\t\t// handle other errors\n\t\t\tfmt.Println(err)\n\t\t}\n\t}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidenhadisi%2Fchat-gpt-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidenhadisi%2Fchat-gpt-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidenhadisi%2Fchat-gpt-go/lists"}