{"id":37021427,"url":"https://github.com/vacuityv/ai-java-sdk","last_synced_at":"2026-01-23T12:38:35.855Z","repository":{"id":226169007,"uuid":"767946190","full_name":"vacuityv/ai-java-sdk","owner":"vacuityv","description":"java sdk for ai apis. Support claude ai and google gemini and part of openai (chatgpt). 支持chatgpt/gemini/claude的java sdk。","archived":false,"fork":false,"pushed_at":"2025-11-21T09:49:51.000Z","size":343,"stargazers_count":46,"open_issues_count":0,"forks_count":13,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2026-01-14T03:41:12.504Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/vacuityv.png","metadata":{"files":{"readme":"README-eng.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"vacuityv","patreon":null,"open_collective":null,"ko_fi":"weipengvacuity","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2024-03-06T07:27:59.000Z","updated_at":"2025-11-27T09:15:13.000Z","dependencies_parsed_at":"2024-03-28T03:41:13.368Z","dependency_job_id":"d79ac74b-cba9-4141-b4d7-324f11fdc739","html_url":"https://github.com/vacuityv/ai-java-sdk","commit_stats":null,"previous_names":["vacuityv/ai-java-sdk"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/vacuityv/ai-java-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacuityv%2Fai-java-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacuityv%2Fai-java-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacuityv%2Fai-java-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacuityv%2Fai-java-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vacuityv","download_url":"https://codeload.github.com/vacuityv/ai-java-sdk/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vacuityv%2Fai-java-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28692002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T11:01:27.039Z","status":"ssl_error","status_checked_at":"2026-01-23T11:00:26.909Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2026-01-14T02:31:39.423Z","updated_at":"2026-01-23T12:38:35.838Z","avatar_url":"https://github.com/vacuityv.png","language":"Java","funding_links":["https://github.com/sponsors/vacuityv","https://ko-fi.com/weipengvacuity"],"categories":["人工智能"],"sub_categories":["LLM客户端"],"readme":"[[中文]](https://github.com/vacuityv/ai-java-sdk/tree/develop) [[English]](https://github.com/vacuityv/ai-java-sdk/blob/develop/README-eng.md)\n\n# AI-Java-Sdk\n\n\u003e Welcome to experience the interactive website connecting individuals with major AI\n\u003e vendors: [AI-CHAT](https://chat.vacuity.me/)\n\nThis is a Java SDK created for utilizing APIs provided by various AI companies. Currently, it supports Claude AI and\nGoogle gemini and part of OpenAI.\n\n## Supported Claude APIs\n\n- [Chat (support function)](https://docs.anthropic.com/claude/reference/messages_post)\n- [Streaming Chat (support function)](https://docs.anthropic.com/claude/reference/messages-streaming)\n\n## Supported Google Gemini\n\n- [Chat (support function)](https://ai.google.dev/tutorials/rest_quickstart)\n- [Streaming Chat (support function)](https://ai.google.dev/tutorials/rest_quickstart)\n\n## Supported openAI\n\n\u003e Support function calls, please refer to OpenaiTest (a large part of the function implementation is based\n\u003e on https://github.com/TheoKanning/openai-java).\n\n- [Chat (support function)](https://platform.openai.com/docs/api-reference/chat/create)\n- [Streaming Chat (support function)](https://platform.openai.com/docs/api-reference/chat/streaming)\n- [File](https://platform.openai.com/docs/api-reference/files)\n- [Assistant (include stream)](https://platform.openai.com/docs/api-reference/assistants)\n- [Image](https://platform.openai.com/docs/api-reference/images)\n\n## Importing\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eme.vacuity.me.ai.sdk\u003c/groupId\u003e\n    \u003cartifactId\u003eai-java-sdk\u003c/artifactId\u003e\n    \u003cversion\u003e${version}\u003c/version\u003e       \n\u003c/dependency\u003e\n```\n\nYou can get the version here：[Maven Central](https://central.sonatype.com/artifact/me.vacuity.ai.sdk/ai-java-sdk)\n\n## Usage\n\nFor regular chat:\n\n```java\n\n@Test\npublic void chat() {\n    ClaudeClient client = new ClaudeClient(API_KEY);\n    List\u003cChatMessage\u003e messages = new ArrayList\u003c\u003e();\n    messages.add(new ChatMessage(\"user\", \"introduce yourself pls\"));\n    ChatRequest request = ChatRequest.builder()\n            .model(\"claude-3-opus-20240229\")\n            .messages(messages)\n            .maxTokens(1024)\n            .build();\n    try {\n        ChatResponse response = client.chat(request);\n        System.out.println(response);\n    } catch (VacException e) {\n        if (e.getDetail() != null) {\n            System.out.println(e.getDetail().getError().getMessage());\n        }\n    }\n}\n```\n\nFor streaming chat:\n\n```java\n\n@Test\npublic void streamChat() {\n    ClaudeClient client = new ClaudeClient(API_KEY);\n    List\u003cChatMessage\u003e messages = new ArrayList\u003c\u003e();\n    messages.add(new ChatMessage(\"user\", \"Why did Lu Xun hit Zhou Shuren\"));\n    ChatRequest request = ChatRequest.builder()\n            .model(\"claude-3-opus-20240229\")\n            .messages(messages)\n            .maxTokens(1024)\n            .build();\n    Flowable\u003cStreamChatResponse\u003e response = client.streamChat(request);\n    response.doOnNext(s -\u003e {\n        if (\"content_block_delta\".equals(s.getType())) {\n            ChatMessageContent content = s.getDelta();\n            System.out.print(content.getText());\n        } else if (\"error\".equals(s.getType())) {\n            System.out.println(s.getError().getMessage());\n        }\n    }).blockingSubscribe();\n}\n```\n\nopenAI vision：\n\n```java\n\n@Test\npublic void vision() throws IOException {\n    String imagePath = \"222.jpg\";\n    Path path = Paths.get(imagePath);\n    // read file\n    byte[] imageBytes = Files.readAllBytes(path);\n\n    InputStream is = new BufferedInputStream(new FileInputStream(imagePath));\n    String mimeType = URLConnection.guessContentTypeFromStream(is);\n\n    // convert image to base64 data\n    String base64Image = Base64.getEncoder().encodeToString(imageBytes);\n    base64Image = \"data:\" + mimeType + \";base64,\" + Base64.getEncoder().encodeToString(imageBytes);\n    String url = \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\";\n\n    OpenaiClient client = new OpenaiClient(API_KEY, Duration.ofSeconds(120));\n    List\u003cChatMessage\u003e messages = new ArrayList\u003c\u003e();\n\n    ChatMessageContent content = new ChatMessageContent();\n    ChatMessageContent.ImageUrl imageUrl = new ChatMessageContent.ImageUrl();\n    // imageUrl.setUrl(url);\n    imageUrl.setUrl(base64Image);\n    content.setType(\"image_url\");\n    content.setImageUrl(imageUrl);\n    ChatMessageContent content2 = new ChatMessageContent();\n    content2.setType(\"text\");\n    content2.setText(\"what is this?\");\n\n    ChatMessage chatMessage = new ChatMessage(\"user\", Arrays.asList(content, content2));\n    messages.add(chatMessage);\n\n    ChatRequest request = ChatRequest.builder()\n            .model(\"gpt-4-vision-preview\")\n            .messages(messages)\n            .build();\n    Flowable\u003cStreamChatResponse\u003e response = client.streamChat(request);\n    response.doOnNext(s -\u003e {\n        System.out.println(s.getSingleContent());\n    }).blockingSubscribe();\n}\n```\n\n### Customizing the URL and Timeout\n\n```java\nClaudeClient client = new ClaudeClient(API_KEY, Duration.ofSeconds(100), \"https://example.com\");\n```\n\n### Using an HTTP Proxy\n\n```java\n\n@Test\npublic void proxyChat() {\n    String host = \"127.0.0.1\";\n    int port = 7890;\n    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));\n\n    ClaudeClient client = new ClaudeClient(API_KEY, Duration.ofSeconds(60), proxy);\n\n    List\u003cChatMessage\u003e messages = new ArrayList\u003c\u003e();\n    messages.add(new ChatMessage(\"user\", \"introduce yourself pls\"));\n    ChatRequest request = ChatRequest.builder()\n            .model(\"claude-3-opus-20240229\")\n            .messages(messages)\n            .maxTokens(1024)\n            .build();\n    try {\n        ChatResponse response = client.chat(request);\n        System.out.println(response.getContent().get(0).getText());\n    } catch (VacSdkException e) {\n        if (e.getDetail() != null) {\n            System.out.println(e.getDetail().getError().getMessage());\n        }\n    }\n}\n```\n\n## Additional Information\n\nYou can view code examples in CludeTest and GeminiTest and OpenaiTest/OpenaiAssistantTest.\n\n## FAQ\n\n### What models are supported?\n\nCurrently, all models of Claude AI and part of gemini and openai are supported.\n\n### Are there many other functions of OpenAI that this SDK does not support?\n\nOpenAI currently has corresponding SDK support on GitHub (such as: https://github.com/TheoKanning/openai-java), so it is\nnot an urgent need, perhaps it will be supported in the future.\n\n## License\n\nPublished under the MIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvacuityv%2Fai-java-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvacuityv%2Fai-java-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvacuityv%2Fai-java-sdk/lists"}