{"id":25627379,"url":"https://github.com/javaaidev/springai-openai-client","last_synced_at":"2026-05-12T12:40:05.794Z","repository":{"id":277400598,"uuid":"932311724","full_name":"JavaAIDev/springai-openai-client","owner":"JavaAIDev","description":"Spring AI ChatModel for OpenAI using official Java SDK, designed for Spring 5","archived":false,"fork":false,"pushed_at":"2025-06-11T22:53:10.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-23T19:50:01.014Z","etag":null,"topics":["java","openai","openai-api","spring-ai","spring-ai-openai"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/JavaAIDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"ko_fi":"alexcheng1982","github":"alexcheng1982"}},"created_at":"2025-02-13T17:55:49.000Z","updated_at":"2025-06-11T22:52:03.000Z","dependencies_parsed_at":"2025-02-13T19:21:50.503Z","dependency_job_id":"a7a567c4-3702-490e-9c24-264976483617","html_url":"https://github.com/JavaAIDev/springai-openai-client","commit_stats":null,"previous_names":["javaaidev/openai-chatmodel-standalone","javaaidev/springai-openai-client"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/JavaAIDev/springai-openai-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaAIDev%2Fspringai-openai-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaAIDev%2Fspringai-openai-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaAIDev%2Fspringai-openai-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaAIDev%2Fspringai-openai-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JavaAIDev","download_url":"https://codeload.github.com/JavaAIDev/springai-openai-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavaAIDev%2Fspringai-openai-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32940102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T09:19:52.626Z","status":"ssl_error","status_checked_at":"2026-05-12T09:17:33.438Z","response_time":102,"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":["java","openai","openai-api","spring-ai","spring-ai-openai"],"created_at":"2025-02-22T17:48:21.409Z","updated_at":"2026-05-12T12:40:05.764Z","avatar_url":"https://github.com/JavaAIDev.png","language":"Kotlin","funding_links":["https://ko-fi.com/alexcheng1982","https://github.com/sponsors/alexcheng1982"],"categories":[],"sub_categories":[],"readme":"# SpringAI OpenAI Client using Official Java SDK\n\n[![build](https://github.com/JavaAIDev/springai-openai-client/actions/workflows/build.yaml/badge.svg)](https://github.com/JavaAIDev/springai-openai-client/actions/workflows/build.yaml)\n![Maven Central Version](https://img.shields.io/maven-central/v/com.javaaidev/springai-openai-client)\n[![javadoc](https://javadoc.io/badge2/com.javaaidev/springai-openai-client/javadoc.svg)](https://javadoc.io/doc/com.javaaidev/springai-openai-client)\n\nSpring AI `ChatModel` and `EmbeddingModel` implementations for OpenAI using\nthe [official SDK](https://github.com/openai/openai-java).\n\nThe motivation of this `ChatModel` and `EmbeddingModel` implementations is to use Spring AI with\nSpring 5.\n\nAdd Maven dependency of the latest version.\n\n```xml\n\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.javaaidev\u003c/groupId\u003e\n  \u003cartifactId\u003espringai-openai-client\u003c/artifactId\u003e\n  \u003cversion\u003e${VERSION}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## ChatModel\n\nSupported features:\n\n- Chat completions\n- Function calling\n- Streaming mode\n\n### Use ChatModel\n\nTo use this `ChatModel`,\n\n1. Create an `OpenAIClient`,\n2. Create an `OpenAIChatModel`,\n3. Create a Spring AI `ChatClient.Builder` with this `ChatModel`,\n4. Create a Spring AI `ChatClient` from `ChatClient.Builder`.\n\nSee the code below:\n\n```kotlin\nval client = OpenAIOkHttpClient.fromEnv()\nval chatModel = OpenAIChatModel(client, \n    DefaultToolCallingManager.builder().toolCallbackResolver(CustomToolCallbackResolver()).build())\nval chatOptions = OpenAiChatOptions.builder()\n    .model(\"gpt-4o-mini\")\n    .build()\nchatClient =\n    ChatClient.builder(chatModel).defaultOptions(chatOptions).build()\nval response = chatClient.prompt().user(\"tell me a joke\")\n    .call().content()\n```\n\n### Streaming\n\nStreaming mode is also supported.\n\n```kotlin\nval builder = StringBuilder()\nchatClient.prompt().user(\"tell me a joke\")\n    .stream().chatResponse().doOnNext {\n        builder.append(it.result.output.text)\n    }.blockLast()\nval result = builder.toString()\n```\n\n## EmbeddingModel\n\nTo use this `EmbeddingModel`,\n\n1. Create an `OpenAIClient`,\n2. Create an `OpenAIEmbeddingModel`\n\nSee the code below:\n\n```kotlin\nval client = OpenAIOkHttpClient.fromEnv()\nval embeddingModel = OpenAIEmbeddingModel(client)\nval response = embeddingModel.call(\n    EmbeddingRequest(\n        listOf(\"hello\", \"world\"),\n        OpenAIEmbeddingOptions.builder()\n            .model(\"text-embedding-3-small\")\n            .build()\n    )\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavaaidev%2Fspringai-openai-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavaaidev%2Fspringai-openai-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavaaidev%2Fspringai-openai-client/lists"}