{"id":38101389,"url":"https://github.com/dashscope/dashscope-sdk-java","last_synced_at":"2026-01-16T21:14:54.013Z","repository":{"id":266246296,"uuid":"882929467","full_name":"dashscope/dashscope-sdk-java","owner":"dashscope","description":"java sdk for dashscope api","archived":false,"fork":false,"pushed_at":"2026-01-13T01:54:54.000Z","size":20772,"stargazers_count":50,"open_issues_count":20,"forks_count":21,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-13T05:21:53.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bailian.console.aliyun.com/","language":"Java","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/dashscope.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-04T04:06:18.000Z","updated_at":"2026-01-13T01:54:58.000Z","dependencies_parsed_at":"2025-06-13T03:18:53.174Z","dependency_job_id":"7cd9ceec-7a9a-4791-959d-8d9c32950f91","html_url":"https://github.com/dashscope/dashscope-sdk-java","commit_stats":null,"previous_names":["dashscope/dashscope-sdk-java"],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/dashscope/dashscope-sdk-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashscope%2Fdashscope-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashscope%2Fdashscope-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashscope%2Fdashscope-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashscope%2Fdashscope-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dashscope","download_url":"https://codeload.github.com/dashscope/dashscope-sdk-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashscope%2Fdashscope-sdk-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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-16T21:14:53.385Z","updated_at":"2026-01-16T21:14:54.008Z","avatar_url":"https://github.com/dashscope.png","language":"Java","funding_links":[],"categories":["人工智能"],"sub_categories":["LLM客户端"],"readme":"# dashscope-sdk-java\n\nThis is the java sdk for the DashScope models.\n\n## Usage\n\nTo use the sdk in your java systems, please add the maven dependency in your pom.xml:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.alibaba\u003c/groupId\u003e\n    \u003cartifactId\u003edashscope-sdk-java\u003c/artifactId\u003e\n    \u003cversion\u003e{dashscope-sdk-java-version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## QuickStart\n\n### Conversation\n\nYou can create a conversation client simply by:\n\n```java\n// Use http as the network protocol.\nConversation conversation = new Conversation();\n```\n\nThis interface also accept a protocol argument:\n\n```java\nimport com.alibaba.dashscope.common.Protocol;\nConversation conversation = new Conversation(Protocol.HTTP.getValue());\nConversation conversation = new Conversation(Protocol.WEBSOCKET.getValue());\n```\n\nThe conversation interface supports both stream and non-stream queries. These queries all accept `ConversationParam`  as input, and returns `ConversationResult` as output . Each model has a unique input structure and output structure which derives from the two data classes mentioned above. Please use these sub classes when you are using the coordinating model. \n\nHere shows the usages of each method, with the examples of `qwen-turbo` model.\n\n#### Support stream and non-stream mode, accept output from callback\n\n```java\nimport com.alibaba.dashscope.common.ResultCallback;\nimport com.alibaba.dashscope.aigc.conversation.Conversation;\nimport com.alibaba.dashscope.aigc.conversation.ConversationResult;\nimport com.alibaba.dashscope.aigc.conversation.qwen.QWenConversationParam;\nimport com.alibaba.dashscope.aigc.conversation.qwen.QWenConversationResult;\nimport com.alibaba.dashscope.exception.ApiException;\n\npublic class Main {\n\n  public static void main(String[] args) {\n    Conversation conversation = new Conversation();\n\n    //QWEN model, if using other model, you can replace the QWenConversationParam here.\n    QWenConversationParam param =\n            QWenConversationParam.builder()\n                    .model(QWenConversationParam.QWEN_TURBO)\n                    //there are other arguments supported.\n                    .prompt(\"hello\")\n                    .apiKey(\"testKey\")\n                    .build();\n\n    class ReactCallback extends ResultCallback\u003cConversationResult\u003e {\n\n      @Override\n      public void onEvent(ConversationResult message) {\n        QWenConversationResult result = (QWenConversationResult) message;\n        // TODO deal with result\n      }\n\n      public void onComplete() {\n        // TODO all messages received\n      }\n\n      public void onError(Exception e) {\n        ApiException apiException = (ApiException) e;\n        // TODO deal with exception\n      }\n    }\n    conversation.call(param, new ReactCallback());\n  }\n}\n\n```\n\nThe Exception instance in the conversation scenario is a `ApiException` instance. This Exception may contain two parts:\n\n- A `Status` instance. This instance carries a status_code(The http error code), a code(server error code), a message(server error message), the input message id, and the usage information.\n- If an exception occurs, the `ApiException` instance may only carry an `Exception` stack trace, you can deal with it as you usually do.\n\n#### Stream only, accept by react io\n\n```java\nimport com.alibaba.dashscope.aigc.conversation.Conversation;\nimport com.alibaba.dashscope.aigc.conversation.ConversationResult;\nimport com.alibaba.dashscope.aigc.conversation.qwen.QWenConversationParam;\nimport com.alibaba.dashscope.common.StreamingMode;\nimport com.alibaba.dashscope.utils.JsonUtils;\nimport io.reactivex.Flowable;\n\npublic class Main {\n\n  public static void main(String[] args) {\n    Conversation conversation = new Conversation();\n\n    //QWEN model, if using other model, you can replace the QWenConversationParam here.\n    QWenConversationParam param =\n            QWenConversationParam.builder().model(QWenConversationParam.QWEN_TURBO).prompt(\"hello\")\n                    .mode(StreamingMode.OUT)\n                    .apiKey(\"testKey\")\n                    .build();\n\n    Flowable\u003cConversationResult\u003e flowable = conversation.streamCall(param);\n    try {\n      flowable.blockingForEach(msg -\u003e System.out.println(JsonUtils.toJson(msg)));\n    } catch (Throwable e) {\n      // TODO deal with error here\n    }\n  }\n}\n```\n\nThe `streamCall` method accepts a `ConversationParam` , and returns a `Flowable`, which you can get the streaming result by `blockingForEach`, and catch the exception by the try-catch block.\n\n#### Non-stream only\n\n```java\nimport com.alibaba.dashscope.aigc.conversation.Conversation;\nimport com.alibaba.dashscope.aigc.conversation.ConversationResult;\nimport com.alibaba.dashscope.aigc.conversation.qwen.QWenConversationParam;\n\npublic class Main {\n\n  public static void main(String[] args) {\n    Conversation conversation = new Conversation();\n\n    //QWEN model, if using other model, you can replace the QWenConversationParam here.\n    QWenConversationParam param =\n            QWenConversationParam.builder()\n                    .model(QWenConversationParam.QWEN_TURBO)\n                    .prompt(\"hello\")\n                    .apiKey(\"testKey\")\n                    .build();\n\n    ConversationResult result = conversation.call(param);\n  }\n}\n```\n\nThe `call` method accepts a `ConversationParam`, and returns a `ConversationResult`, you can also catch the exception with a try-catch block.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashscope%2Fdashscope-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdashscope%2Fdashscope-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashscope%2Fdashscope-sdk-java/lists"}