{"id":21148689,"url":"https://github.com/rainnny7/openai-java","last_synced_at":"2026-05-06T04:32:05.347Z","repository":{"id":179577376,"uuid":"663726113","full_name":"Rainnny7/OpenAI-Java","owner":"Rainnny7","description":"A Java library to interact with the OpenAI API.","archived":false,"fork":false,"pushed_at":"2023-08-08T00:13:54.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-31T11:38:04.661Z","etag":null,"topics":["api","chatgpt","java","library","maven","openai"],"latest_commit_sha":null,"homepage":"https://git.rainnny.club/Rainnny/OpenAI-Java","language":"Java","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/Rainnny7.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":"2023-07-08T00:48:29.000Z","updated_at":"2023-07-12T08:06:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"a300d415-84b9-4fc0-bcbb-7bccabe17dc4","html_url":"https://github.com/Rainnny7/OpenAI-Java","commit_stats":null,"previous_names":["rainnny7/openai-java"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rainnny7/OpenAI-Java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rainnny7%2FOpenAI-Java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rainnny7%2FOpenAI-Java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rainnny7%2FOpenAI-Java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rainnny7%2FOpenAI-Java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rainnny7","download_url":"https://codeload.github.com/Rainnny7/OpenAI-Java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rainnny7%2FOpenAI-Java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32678594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T02:33:58.958Z","status":"ssl_error","status_checked_at":"2026-05-06T02:33:39.611Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","chatgpt","java","library","maven","openai"],"created_at":"2024-11-20T09:28:17.312Z","updated_at":"2026-05-06T04:32:05.325Z","avatar_url":"https://github.com/Rainnny7.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI-Java\nA Java library to interact with the OpenAI API.\n\n## Summary\n- [Dependency](#dependency)\n- [Examples](#examples)\n- [Environment Variables](#environment-variables)\n- [Todo](#todo)\n\n## Dependency\n\n### Maven\n```xml\n\u003crepository\u003e\n    \u003cid\u003erainnny-repo-public\u003c/id\u003e\n    \u003curl\u003ehttps://maven.rainnny.club/public\u003c/url\u003e\n\u003c/repository\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eme.braydon\u003c/groupId\u003e\n    \u003cartifactId\u003eOpenAI-Java\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n```\nmaven {\n    name = \"rainnnyRepoPublic\"\n    url = uri(\"https://maven.rainnny.club/public\")\n}\n\nimplementation(\"me.braydon:OpenAI-Java:1.0.0\")\n```\n\n## Examples\n\n### Create the client\n```java\nOpenAI openAi = new OpenAI(ApiCredentials.builder()\n                    .apiKey(\"YOUR_API_KEY\")\n                    .organization(\"OPTIONAL_ORG\")\n                    .build());\n```\n\n### List Models\n```java\nfor (Model model : openAi.models()) {\n    System.out.println(String.format(\"Model %s is owned by %s\", model.getId(), model.getOwnedBy()));\n    // Model gpt-3.5-turbo is owned by openai\n}\n```\n\n### Get Specific Model\n```java\nModel model = openAi.getModel(ModelEnum.GPT_3_5_TURBO);\nSystem.out.println(\"Found \" + model.getId());\n// Found gpt-3.5-turbo\n```\n\n### Chat Completion\n```java\nChatCompletion completion = openAi.chatCompletion(ModelEnum.GPT_3_5_TURBO,\n    new ChatMessage(\"user\", \"Do a dice roll\")\n);\nSystem.out.println(\"Got \" + completion.choiceCount() + \" choice(s):\");\nfor (ChatCompletion.Choice choice : completion) {\n    ChatMessage message = choice.getMessage();\n    System.out.println(String.format(\"  %s (%s): %s\", choice.getIndex(), message.getRole(), message.getContent()));\n}\n/**\n * Got 1 choice(s):\n *   0 (assistant): Sure! Here's a dice roll for you:\n *                  You rolled a 4.\n */\n```\n## Environment Variables\n*Environment variables are required for running tests.*\n\n| Variable       | Description                         |\n| :------------: | :---------------------------------: |\n| `TEST_API_KEY` | **Required**. Your OpenAI API key   |\n\n## TODO\n- [ ] SSE implementation for streaming completions\n- [ ] A better interface approach for the API\n- [ ] Support for other routes\n- [ ] More in depth multithreading capabilities","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainnny7%2Fopenai-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frainnny7%2Fopenai-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frainnny7%2Fopenai-java/lists"}