diff --git a/sdk/machinelearning/azure-ai-chatprotocol/CHANGELOG.md b/sdk/machinelearning/azure-ai-chatprotocol/CHANGELOG.md
new file mode 100644
index 000000000000..ebad61c265d6
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/CHANGELOG.md
@@ -0,0 +1,13 @@
+# Release History
+
+## 1.0.0-beta.1 (Unreleased)
+
+- Azure ChatProtocol client library for Java. This package contains Microsoft Azure ChatProtocol client library.
+
+### Features Added
+
+### Breaking Changes
+
+### Bugs Fixed
+
+### Other Changes
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/README.md b/sdk/machinelearning/azure-ai-chatprotocol/README.md
new file mode 100644
index 000000000000..890b38249da8
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/README.md
@@ -0,0 +1,78 @@
+# Azure ChatProtocol client library for Java
+
+Azure ChatProtocol client library for Java.
+
+This package contains Microsoft Azure ChatProtocol client library.
+
+## Documentation
+
+Various documentation is available to help you get started
+
+- [API reference documentation][docs]
+- [Product documentation][product_documentation]
+
+## Getting started
+
+### Prerequisites
+
+- [Java Development Kit (JDK)][jdk] with version 8 or above
+- [Azure Subscription][azure_subscription]
+
+### Adding the package to your product
+
+[//]: # ({x-version-update-start;com.azure:azure-ai-chatprotocol;current})
+```xml
+
+ com.azure
+ azure-ai-chatprotocol
+ 1.0.0-beta.1
+
+```
+[//]: # ({x-version-update-end})
+
+### Authentication
+
+[Azure Identity][azure_identity] package provides the default implementation for authenticating the client.
+
+## Key concepts
+
+## Examples
+
+```java com.azure.ai.chatprotocol.readme
+```
+
+### Service API versions
+
+The client library targets the latest service API version by default.
+The service client builder accepts an optional service API version parameter to specify which API version to communicate.
+
+#### Select a service API version
+
+You have the flexibility to explicitly select a supported service API version when initializing a service client via the service client builder.
+This ensures that the client can communicate with services using the specified API version.
+
+When selecting an API version, it is important to verify that there are no breaking changes compared to the latest API version.
+If there are significant differences, API calls may fail due to incompatibility.
+
+Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy.
+
+## Troubleshooting
+
+## Next steps
+
+## Contributing
+
+For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md).
+
+1. Fork it
+1. Create your feature branch (`git checkout -b my-new-feature`)
+1. Commit your changes (`git commit -am 'Add some feature'`)
+1. Push to the branch (`git push origin my-new-feature`)
+1. Create new Pull Request
+
+
+[product_documentation]: https://azure.microsoft.com/services/
+[docs]: https://azure.github.io/azure-sdk-for-java/
+[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/
+[azure_subscription]: https://azure.microsoft.com/free/
+[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/assets.json b/sdk/machinelearning/azure-ai-chatprotocol/assets.json
new file mode 100644
index 000000000000..7de081c85a2e
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/assets.json
@@ -0,0 +1 @@
+{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/machinelearning/azure-ai-chatprotocol","Tag":""}
\ No newline at end of file
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/pom.xml b/sdk/machinelearning/azure-ai-chatprotocol/pom.xml
new file mode 100644
index 000000000000..b078d9cce138
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/pom.xml
@@ -0,0 +1,71 @@
+
+
+ 4.0.0
+
+ com.azure
+ azure-client-sdk-parent
+ 1.7.0
+ ../../parents/azure-client-sdk-parent
+
+
+ com.azure
+ azure-ai-chatprotocol
+ 1.0.0-beta.1
+ jar
+
+ Microsoft Azure SDK for ChatProtocol
+ This package contains Microsoft Azure ChatProtocol client library.
+ https://github.com/Azure/azure-sdk-for-java
+
+
+
+ The MIT License (MIT)
+ http://opensource.org/licenses/MIT
+ repo
+
+
+
+
+ https://github.com/Azure/azure-sdk-for-java
+ scm:git:git@github.com:Azure/azure-sdk-for-java.git
+ scm:git:git@github.com:Azure/azure-sdk-for-java.git
+ HEAD
+
+
+
+ microsoft
+ Microsoft
+
+
+
+ UTF-8
+
+
+
+ com.azure
+ azure-core
+ 1.55.3
+
+
+ com.azure
+ azure-core-http-netty
+ 1.15.11
+
+
+ com.azure
+ azure-core-test
+ 1.27.0-beta.8
+ test
+
+
+ com.azure
+ azure-identity
+ 1.15.4
+ test
+
+
+
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolAsyncClient.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolAsyncClient.java
new file mode 100644
index 000000000000..8ff4368cbda0
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolAsyncClient.java
@@ -0,0 +1,292 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol;
+
+import com.azure.ai.chatprotocol.implementation.ChatsImpl;
+import com.azure.ai.chatprotocol.implementation.models.CreateRequest;
+import com.azure.ai.chatprotocol.implementation.models.CreateStreamingRequest;
+import com.azure.ai.chatprotocol.models.ChatCompletion;
+import com.azure.ai.chatprotocol.models.ChatCompletionChunk;
+import com.azure.ai.chatprotocol.models.ChatMessage;
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceClient;
+import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.exception.ClientAuthenticationException;
+import com.azure.core.exception.HttpResponseException;
+import com.azure.core.exception.ResourceModifiedException;
+import com.azure.core.exception.ResourceNotFoundException;
+import com.azure.core.http.rest.RequestOptions;
+import com.azure.core.http.rest.Response;
+import com.azure.core.util.BinaryData;
+import com.azure.core.util.FluxUtil;
+import java.util.List;
+import java.util.Map;
+import reactor.core.publisher.Mono;
+
+/**
+ * Initializes a new instance of the asynchronous ChatProtocolClient type.
+ */
+@ServiceClient(builder = ChatProtocolClientBuilder.class, isAsync = true)
+public final class ChatProtocolAsyncClient {
+ @Generated
+ private final ChatsImpl serviceClient;
+
+ /**
+ * Initializes an instance of ChatProtocolAsyncClient class.
+ *
+ * @param serviceClient the service client implementation.
+ */
+ @Generated
+ ChatProtocolAsyncClient(ChatsImpl serviceClient) {
+ this.serviceClient = serviceClient;
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ *
Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * delta (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Optional)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Optional)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createStreamingRequest The createStreamingRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return a single response to a streaming completion request along with {@link Response} on successful completion
+ * of {@link Mono}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createStreamingWithResponse(String operationRoute,
+ BinaryData createStreamingRequest, RequestOptions requestOptions) {
+ return this.serviceClient.createStreamingWithResponseAsync(operationRoute, createStreamingRequest,
+ requestOptions);
+ }
+
+ /**
+ * Creates a new chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * message (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Required)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createRequest The createRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return representation of the response to a chat completion request along with {@link Response} on successful
+ * completion of {@link Mono}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createWithResponse(String operationRoute, BinaryData createRequest,
+ RequestOptions requestOptions) {
+ return this.serviceClient.createWithResponseAsync(operationRoute, createRequest, requestOptions);
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @param sessionState Field that allows the chat app to store and retrieve data, the structure of such data is
+ * dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ * @param context Context allows the chat app to receive extra parameters from the client, such as temperature,
+ * functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return a single response to a streaming completion request on successful completion of {@link Mono}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono createStreaming(String operationRoute, List messages,
+ BinaryData sessionState, Map context) {
+ // Generated convenience method for createStreamingWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateStreamingRequest createStreamingRequestObj
+ = new CreateStreamingRequest(messages).setSessionState(sessionState).setContext(context);
+ BinaryData createStreamingRequest = BinaryData.fromObject(createStreamingRequestObj);
+ return createStreamingWithResponse(operationRoute, createStreamingRequest, requestOptions)
+ .flatMap(FluxUtil::toMono)
+ .map(protocolMethodData -> protocolMethodData.toObject(ChatCompletionChunk.class));
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return a single response to a streaming completion request on successful completion of {@link Mono}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono createStreaming(String operationRoute, List messages) {
+ // Generated convenience method for createStreamingWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateStreamingRequest createStreamingRequestObj = new CreateStreamingRequest(messages);
+ BinaryData createStreamingRequest = BinaryData.fromObject(createStreamingRequestObj);
+ return createStreamingWithResponse(operationRoute, createStreamingRequest, requestOptions)
+ .flatMap(FluxUtil::toMono)
+ .map(protocolMethodData -> protocolMethodData.toObject(ChatCompletionChunk.class));
+ }
+
+ /**
+ * Creates a new chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @param sessionState Field that allows the chat app to store and retrieve data, the structure of such data is
+ * dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ * @param context Context allows the chat app to receive extra parameters from the client, such as temperature,
+ * functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return representation of the response to a chat completion request on successful completion of {@link Mono}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono create(String operationRoute, List messages, BinaryData sessionState,
+ Map context) {
+ // Generated convenience method for createWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateRequest createRequestObj = new CreateRequest(messages).setSessionState(sessionState).setContext(context);
+ BinaryData createRequest = BinaryData.fromObject(createRequestObj);
+ return createWithResponse(operationRoute, createRequest, requestOptions).flatMap(FluxUtil::toMono)
+ .map(protocolMethodData -> protocolMethodData.toObject(ChatCompletion.class));
+ }
+
+ /**
+ * Creates a new chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return representation of the response to a chat completion request on successful completion of {@link Mono}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono create(String operationRoute, List messages) {
+ // Generated convenience method for createWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateRequest createRequestObj = new CreateRequest(messages);
+ BinaryData createRequest = BinaryData.fromObject(createRequestObj);
+ return createWithResponse(operationRoute, createRequest, requestOptions).flatMap(FluxUtil::toMono)
+ .map(protocolMethodData -> protocolMethodData.toObject(ChatCompletion.class));
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolClient.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolClient.java
new file mode 100644
index 000000000000..9b2036d9d9d0
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolClient.java
@@ -0,0 +1,285 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol;
+
+import com.azure.ai.chatprotocol.implementation.ChatsImpl;
+import com.azure.ai.chatprotocol.implementation.models.CreateRequest;
+import com.azure.ai.chatprotocol.implementation.models.CreateStreamingRequest;
+import com.azure.ai.chatprotocol.models.ChatCompletion;
+import com.azure.ai.chatprotocol.models.ChatCompletionChunk;
+import com.azure.ai.chatprotocol.models.ChatMessage;
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceClient;
+import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.exception.ClientAuthenticationException;
+import com.azure.core.exception.HttpResponseException;
+import com.azure.core.exception.ResourceModifiedException;
+import com.azure.core.exception.ResourceNotFoundException;
+import com.azure.core.http.rest.RequestOptions;
+import com.azure.core.http.rest.Response;
+import com.azure.core.util.BinaryData;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Initializes a new instance of the synchronous ChatProtocolClient type.
+ */
+@ServiceClient(builder = ChatProtocolClientBuilder.class)
+public final class ChatProtocolClient {
+ @Generated
+ private final ChatsImpl serviceClient;
+
+ /**
+ * Initializes an instance of ChatProtocolClient class.
+ *
+ * @param serviceClient the service client implementation.
+ */
+ @Generated
+ ChatProtocolClient(ChatsImpl serviceClient) {
+ this.serviceClient = serviceClient;
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * delta (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Optional)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Optional)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createStreamingRequest The createStreamingRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return a single response to a streaming completion request along with {@link Response}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createStreamingWithResponse(String operationRoute, BinaryData createStreamingRequest,
+ RequestOptions requestOptions) {
+ return this.serviceClient.createStreamingWithResponse(operationRoute, createStreamingRequest, requestOptions);
+ }
+
+ /**
+ * Creates a new chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * message (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Required)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createRequest The createRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return representation of the response to a chat completion request along with {@link Response}.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createWithResponse(String operationRoute, BinaryData createRequest,
+ RequestOptions requestOptions) {
+ return this.serviceClient.createWithResponse(operationRoute, createRequest, requestOptions);
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @param sessionState Field that allows the chat app to store and retrieve data, the structure of such data is
+ * dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ * @param context Context allows the chat app to receive extra parameters from the client, such as temperature,
+ * functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return a single response to a streaming completion request.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public ChatCompletionChunk createStreaming(String operationRoute, List messages,
+ BinaryData sessionState, Map context) {
+ // Generated convenience method for createStreamingWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateStreamingRequest createStreamingRequestObj
+ = new CreateStreamingRequest(messages).setSessionState(sessionState).setContext(context);
+ BinaryData createStreamingRequest = BinaryData.fromObject(createStreamingRequestObj);
+ return createStreamingWithResponse(operationRoute, createStreamingRequest, requestOptions).getValue()
+ .toObject(ChatCompletionChunk.class);
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return a single response to a streaming completion request.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public ChatCompletionChunk createStreaming(String operationRoute, List messages) {
+ // Generated convenience method for createStreamingWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateStreamingRequest createStreamingRequestObj = new CreateStreamingRequest(messages);
+ BinaryData createStreamingRequest = BinaryData.fromObject(createStreamingRequestObj);
+ return createStreamingWithResponse(operationRoute, createStreamingRequest, requestOptions).getValue()
+ .toObject(ChatCompletionChunk.class);
+ }
+
+ /**
+ * Creates a new chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @param sessionState Field that allows the chat app to store and retrieve data, the structure of such data is
+ * dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ * @param context Context allows the chat app to receive extra parameters from the client, such as temperature,
+ * functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return representation of the response to a chat completion request.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public ChatCompletion create(String operationRoute, List messages, BinaryData sessionState,
+ Map context) {
+ // Generated convenience method for createWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateRequest createRequestObj = new CreateRequest(messages).setSessionState(sessionState).setContext(context);
+ BinaryData createRequest = BinaryData.fromObject(createRequestObj);
+ return createWithResponse(operationRoute, createRequest, requestOptions).getValue()
+ .toObject(ChatCompletion.class);
+ }
+
+ /**
+ * Creates a new chat completion.
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param messages The collection of context messages associated with this completion request.
+ * @throws IllegalArgumentException thrown if parameters fail the validation.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
+ * @return representation of the response to a chat completion request.
+ */
+ @Generated
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public ChatCompletion create(String operationRoute, List messages) {
+ // Generated convenience method for createWithResponse
+ RequestOptions requestOptions = new RequestOptions();
+ CreateRequest createRequestObj = new CreateRequest(messages);
+ BinaryData createRequest = BinaryData.fromObject(createRequestObj);
+ return createWithResponse(operationRoute, createRequest, requestOptions).getValue()
+ .toObject(ChatCompletion.class);
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolClientBuilder.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolClientBuilder.java
new file mode 100644
index 000000000000..7e5d7e65df6d
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolClientBuilder.java
@@ -0,0 +1,352 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol;
+
+import com.azure.ai.chatprotocol.implementation.ChatProtocolClientImpl;
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.ServiceClientBuilder;
+import com.azure.core.client.traits.ConfigurationTrait;
+import com.azure.core.client.traits.EndpointTrait;
+import com.azure.core.client.traits.HttpTrait;
+import com.azure.core.client.traits.KeyCredentialTrait;
+import com.azure.core.client.traits.TokenCredentialTrait;
+import com.azure.core.credential.KeyCredential;
+import com.azure.core.credential.TokenCredential;
+import com.azure.core.http.HttpClient;
+import com.azure.core.http.HttpHeaders;
+import com.azure.core.http.HttpPipeline;
+import com.azure.core.http.HttpPipelineBuilder;
+import com.azure.core.http.HttpPipelinePosition;
+import com.azure.core.http.policy.AddDatePolicy;
+import com.azure.core.http.policy.AddHeadersFromContextPolicy;
+import com.azure.core.http.policy.AddHeadersPolicy;
+import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
+import com.azure.core.http.policy.HttpLogOptions;
+import com.azure.core.http.policy.HttpLoggingPolicy;
+import com.azure.core.http.policy.HttpPipelinePolicy;
+import com.azure.core.http.policy.HttpPolicyProviders;
+import com.azure.core.http.policy.KeyCredentialPolicy;
+import com.azure.core.http.policy.RequestIdPolicy;
+import com.azure.core.http.policy.RetryOptions;
+import com.azure.core.http.policy.RetryPolicy;
+import com.azure.core.http.policy.UserAgentPolicy;
+import com.azure.core.util.ClientOptions;
+import com.azure.core.util.Configuration;
+import com.azure.core.util.CoreUtils;
+import com.azure.core.util.builder.ClientBuilderUtil;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.serializer.JacksonAdapter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * A builder for creating a new instance of the ChatProtocolClient type.
+ */
+@ServiceClientBuilder(serviceClients = { ChatProtocolClient.class, ChatProtocolAsyncClient.class })
+public final class ChatProtocolClientBuilder implements HttpTrait,
+ ConfigurationTrait, TokenCredentialTrait,
+ KeyCredentialTrait, EndpointTrait {
+ @Generated
+ private static final String SDK_NAME = "name";
+
+ @Generated
+ private static final String SDK_VERSION = "version";
+
+ @Generated
+ private static final Map PROPERTIES = CoreUtils.getProperties("azure-ai-chatprotocol.properties");
+
+ @Generated
+ private final List pipelinePolicies;
+
+ /**
+ * Create an instance of the ChatProtocolClientBuilder.
+ */
+ @Generated
+ public ChatProtocolClientBuilder() {
+ this.pipelinePolicies = new ArrayList<>();
+ }
+
+ /*
+ * The HTTP pipeline to send requests through.
+ */
+ @Generated
+ private HttpPipeline pipeline;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder pipeline(HttpPipeline pipeline) {
+ if (this.pipeline != null && pipeline == null) {
+ LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured.");
+ }
+ this.pipeline = pipeline;
+ return this;
+ }
+
+ /*
+ * The HTTP client used to send the request.
+ */
+ @Generated
+ private HttpClient httpClient;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder httpClient(HttpClient httpClient) {
+ this.httpClient = httpClient;
+ return this;
+ }
+
+ /*
+ * The logging configuration for HTTP requests and responses.
+ */
+ @Generated
+ private HttpLogOptions httpLogOptions;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) {
+ this.httpLogOptions = httpLogOptions;
+ return this;
+ }
+
+ /*
+ * The client options such as application ID and custom headers to set on a request.
+ */
+ @Generated
+ private ClientOptions clientOptions;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder clientOptions(ClientOptions clientOptions) {
+ this.clientOptions = clientOptions;
+ return this;
+ }
+
+ /*
+ * The retry options to configure retry policy for failed requests.
+ */
+ @Generated
+ private RetryOptions retryOptions;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder retryOptions(RetryOptions retryOptions) {
+ this.retryOptions = retryOptions;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder addPolicy(HttpPipelinePolicy customPolicy) {
+ Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null.");
+ pipelinePolicies.add(customPolicy);
+ return this;
+ }
+
+ /*
+ * The configuration store that is used during construction of the service client.
+ */
+ @Generated
+ private Configuration configuration;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder configuration(Configuration configuration) {
+ this.configuration = configuration;
+ return this;
+ }
+
+ /*
+ * The TokenCredential used for authentication.
+ */
+ @Generated
+ private TokenCredential tokenCredential;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder credential(TokenCredential tokenCredential) {
+ this.tokenCredential = tokenCredential;
+ return this;
+ }
+
+ /*
+ * The KeyCredential used for authentication.
+ */
+ @Generated
+ private KeyCredential keyCredential;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder credential(KeyCredential keyCredential) {
+ this.keyCredential = keyCredential;
+ return this;
+ }
+
+ /*
+ * The service endpoint
+ */
+ @Generated
+ private String endpoint;
+
+ /**
+ * {@inheritDoc}.
+ */
+ @Generated
+ @Override
+ public ChatProtocolClientBuilder endpoint(String endpoint) {
+ this.endpoint = endpoint;
+ return this;
+ }
+
+ /*
+ * Service version
+ */
+ @Generated
+ private ChatProtocolServiceVersion serviceVersion;
+
+ /**
+ * Sets Service version.
+ *
+ * @param serviceVersion the serviceVersion value.
+ * @return the ChatProtocolClientBuilder.
+ */
+ @Generated
+ public ChatProtocolClientBuilder serviceVersion(ChatProtocolServiceVersion serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ return this;
+ }
+
+ /*
+ * The retry policy that will attempt to retry failed requests, if applicable.
+ */
+ @Generated
+ private RetryPolicy retryPolicy;
+
+ /**
+ * Sets The retry policy that will attempt to retry failed requests, if applicable.
+ *
+ * @param retryPolicy the retryPolicy value.
+ * @return the ChatProtocolClientBuilder.
+ */
+ @Generated
+ public ChatProtocolClientBuilder retryPolicy(RetryPolicy retryPolicy) {
+ this.retryPolicy = retryPolicy;
+ return this;
+ }
+
+ /**
+ * Builds an instance of ChatProtocolClientImpl with the provided parameters.
+ *
+ * @return an instance of ChatProtocolClientImpl.
+ */
+ @Generated
+ private ChatProtocolClientImpl buildInnerClient() {
+ this.validateClient();
+ HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline();
+ ChatProtocolServiceVersion localServiceVersion
+ = (serviceVersion != null) ? serviceVersion : ChatProtocolServiceVersion.getLatest();
+ ChatProtocolClientImpl client = new ChatProtocolClientImpl(localPipeline,
+ JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion);
+ return client;
+ }
+
+ @Generated
+ private void validateClient() {
+ // This method is invoked from 'buildInnerClient'/'buildClient' method.
+ // Developer can customize this method, to validate that the necessary conditions are met for the new client.
+ Objects.requireNonNull(endpoint, "'endpoint' cannot be null.");
+ }
+
+ @Generated
+ private HttpPipeline createHttpPipeline() {
+ Configuration buildConfiguration
+ = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
+ HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions;
+ ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions;
+ List policies = new ArrayList<>();
+ String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
+ String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion");
+ String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions);
+ policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration));
+ policies.add(new RequestIdPolicy());
+ policies.add(new AddHeadersFromContextPolicy());
+ HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions);
+ if (headers != null) {
+ policies.add(new AddHeadersPolicy(headers));
+ }
+ this.pipelinePolicies.stream()
+ .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
+ .forEach(p -> policies.add(p));
+ HttpPolicyProviders.addBeforeRetryPolicies(policies);
+ policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy()));
+ policies.add(new AddDatePolicy());
+ if (keyCredential != null) {
+ policies.add(new KeyCredentialPolicy("api-key", keyCredential));
+ }
+ if (tokenCredential != null) {
+ policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint)));
+ }
+ this.pipelinePolicies.stream()
+ .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
+ .forEach(p -> policies.add(p));
+ HttpPolicyProviders.addAfterRetryPolicies(policies);
+ policies.add(new HttpLoggingPolicy(localHttpLogOptions));
+ HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0]))
+ .httpClient(httpClient)
+ .clientOptions(localClientOptions)
+ .build();
+ return httpPipeline;
+ }
+
+ /**
+ * Builds an instance of ChatProtocolAsyncClient class.
+ *
+ * @return an instance of ChatProtocolAsyncClient.
+ */
+ @Generated
+ public ChatProtocolAsyncClient buildAsyncClient() {
+ return new ChatProtocolAsyncClient(buildInnerClient().getChats());
+ }
+
+ /**
+ * Builds an instance of ChatProtocolClient class.
+ *
+ * @return an instance of ChatProtocolClient.
+ */
+ @Generated
+ public ChatProtocolClient buildClient() {
+ return new ChatProtocolClient(buildInnerClient().getChats());
+ }
+
+ private static final ClientLogger LOGGER = new ClientLogger(ChatProtocolClientBuilder.class);
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolServiceVersion.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolServiceVersion.java
new file mode 100644
index 000000000000..51933a0f6731
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/ChatProtocolServiceVersion.java
@@ -0,0 +1,40 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol;
+
+import com.azure.core.util.ServiceVersion;
+
+/**
+ * Service version of ChatProtocolClient.
+ */
+public enum ChatProtocolServiceVersion implements ServiceVersion {
+ /**
+ * Enum value 2023-10-01-preview.
+ */
+ V2023_10_01_PREVIEW("2023-10-01-preview");
+
+ private final String version;
+
+ ChatProtocolServiceVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getVersion() {
+ return this.version;
+ }
+
+ /**
+ * Gets the latest service version supported by this client library.
+ *
+ * @return The latest {@link ChatProtocolServiceVersion}.
+ */
+ public static ChatProtocolServiceVersion getLatest() {
+ return V2023_10_01_PREVIEW;
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/ChatProtocolClientImpl.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/ChatProtocolClientImpl.java
new file mode 100644
index 000000000000..db642afcfb52
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/ChatProtocolClientImpl.java
@@ -0,0 +1,127 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.implementation;
+
+import com.azure.ai.chatprotocol.ChatProtocolServiceVersion;
+import com.azure.core.http.HttpPipeline;
+import com.azure.core.http.HttpPipelineBuilder;
+import com.azure.core.http.policy.RetryPolicy;
+import com.azure.core.http.policy.UserAgentPolicy;
+import com.azure.core.util.serializer.JacksonAdapter;
+import com.azure.core.util.serializer.SerializerAdapter;
+
+/**
+ * Initializes a new instance of the ChatProtocolClient type.
+ */
+public final class ChatProtocolClientImpl {
+ /**
+ */
+ private final String endpoint;
+
+ /**
+ * Gets.
+ *
+ * @return the endpoint value.
+ */
+ public String getEndpoint() {
+ return this.endpoint;
+ }
+
+ /**
+ * Service version.
+ */
+ private final ChatProtocolServiceVersion serviceVersion;
+
+ /**
+ * Gets Service version.
+ *
+ * @return the serviceVersion value.
+ */
+ public ChatProtocolServiceVersion getServiceVersion() {
+ return this.serviceVersion;
+ }
+
+ /**
+ * The HTTP pipeline to send requests through.
+ */
+ private final HttpPipeline httpPipeline;
+
+ /**
+ * Gets The HTTP pipeline to send requests through.
+ *
+ * @return the httpPipeline value.
+ */
+ public HttpPipeline getHttpPipeline() {
+ return this.httpPipeline;
+ }
+
+ /**
+ * The serializer to serialize an object into a string.
+ */
+ private final SerializerAdapter serializerAdapter;
+
+ /**
+ * Gets The serializer to serialize an object into a string.
+ *
+ * @return the serializerAdapter value.
+ */
+ public SerializerAdapter getSerializerAdapter() {
+ return this.serializerAdapter;
+ }
+
+ /**
+ * The ChatsImpl object to access its operations.
+ */
+ private final ChatsImpl chats;
+
+ /**
+ * Gets the ChatsImpl object to access its operations.
+ *
+ * @return the ChatsImpl object.
+ */
+ public ChatsImpl getChats() {
+ return this.chats;
+ }
+
+ /**
+ * Initializes an instance of ChatProtocolClient client.
+ *
+ * @param endpoint
+ * @param serviceVersion Service version.
+ */
+ public ChatProtocolClientImpl(String endpoint, ChatProtocolServiceVersion serviceVersion) {
+ this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(),
+ JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion);
+ }
+
+ /**
+ * Initializes an instance of ChatProtocolClient client.
+ *
+ * @param httpPipeline The HTTP pipeline to send requests through.
+ * @param endpoint
+ * @param serviceVersion Service version.
+ */
+ public ChatProtocolClientImpl(HttpPipeline httpPipeline, String endpoint,
+ ChatProtocolServiceVersion serviceVersion) {
+ this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion);
+ }
+
+ /**
+ * Initializes an instance of ChatProtocolClient client.
+ *
+ * @param httpPipeline The HTTP pipeline to send requests through.
+ * @param serializerAdapter The serializer to serialize an object into a string.
+ * @param endpoint
+ * @param serviceVersion Service version.
+ */
+ public ChatProtocolClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint,
+ ChatProtocolServiceVersion serviceVersion) {
+ this.httpPipeline = httpPipeline;
+ this.serializerAdapter = serializerAdapter;
+ this.endpoint = endpoint;
+ this.serviceVersion = serviceVersion;
+ this.chats = new ChatsImpl(this);
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/ChatsImpl.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/ChatsImpl.java
new file mode 100644
index 000000000000..9a1aa767b11e
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/ChatsImpl.java
@@ -0,0 +1,377 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.implementation;
+
+import com.azure.ai.chatprotocol.ChatProtocolServiceVersion;
+import com.azure.core.annotation.BodyParam;
+import com.azure.core.annotation.ExpectedResponses;
+import com.azure.core.annotation.HeaderParam;
+import com.azure.core.annotation.Host;
+import com.azure.core.annotation.HostParam;
+import com.azure.core.annotation.PathParam;
+import com.azure.core.annotation.Post;
+import com.azure.core.annotation.ReturnType;
+import com.azure.core.annotation.ServiceInterface;
+import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.annotation.UnexpectedResponseExceptionType;
+import com.azure.core.exception.ClientAuthenticationException;
+import com.azure.core.exception.HttpResponseException;
+import com.azure.core.exception.ResourceModifiedException;
+import com.azure.core.exception.ResourceNotFoundException;
+import com.azure.core.http.rest.RequestOptions;
+import com.azure.core.http.rest.Response;
+import com.azure.core.http.rest.RestProxy;
+import com.azure.core.util.BinaryData;
+import com.azure.core.util.Context;
+import com.azure.core.util.FluxUtil;
+import reactor.core.publisher.Mono;
+
+/**
+ * An instance of this class provides access to all the operations defined in Chats.
+ */
+public final class ChatsImpl {
+ /**
+ * The proxy service used to perform REST calls.
+ */
+ private final ChatsService service;
+
+ /**
+ * The service client containing this operation class.
+ */
+ private final ChatProtocolClientImpl client;
+
+ /**
+ * Initializes an instance of ChatsImpl.
+ *
+ * @param client the instance of the service client containing this operation class.
+ */
+ ChatsImpl(ChatProtocolClientImpl client) {
+ this.service = RestProxy.create(ChatsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
+ this.client = client;
+ }
+
+ /**
+ * Gets Service version.
+ *
+ * @return the serviceVersion value.
+ */
+ public ChatProtocolServiceVersion getServiceVersion() {
+ return client.getServiceVersion();
+ }
+
+ /**
+ * The interface defining all the services for ChatProtocolClientChats to be used by the proxy service to perform
+ * REST calls.
+ */
+ @Host("{endpoint}")
+ @ServiceInterface(name = "ChatProtocolClientCh")
+ public interface ChatsService {
+ @Post("/{operationRoute}")
+ @ExpectedResponses({ 200 })
+ @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 })
+ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
+ @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
+ @UnexpectedResponseExceptionType(HttpResponseException.class)
+ Mono> createStreaming(@HostParam("endpoint") String endpoint,
+ @PathParam("operationRoute") String operationRoute, @HeaderParam("Content-Type") String contentType,
+ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createStreamingRequest,
+ RequestOptions requestOptions, Context context);
+
+ @Post("/{operationRoute}")
+ @ExpectedResponses({ 200 })
+ @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 })
+ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
+ @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
+ @UnexpectedResponseExceptionType(HttpResponseException.class)
+ Response createStreamingSync(@HostParam("endpoint") String endpoint,
+ @PathParam("operationRoute") String operationRoute, @HeaderParam("Content-Type") String contentType,
+ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createStreamingRequest,
+ RequestOptions requestOptions, Context context);
+
+ @Post("/{operationRoute}")
+ @ExpectedResponses({ 200 })
+ @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 })
+ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
+ @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
+ @UnexpectedResponseExceptionType(HttpResponseException.class)
+ Mono> create(@HostParam("endpoint") String endpoint,
+ @PathParam("operationRoute") String operationRoute, @HeaderParam("Content-Type") String contentType,
+ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createRequest,
+ RequestOptions requestOptions, Context context);
+
+ @Post("/{operationRoute}")
+ @ExpectedResponses({ 200 })
+ @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 })
+ @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
+ @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
+ @UnexpectedResponseExceptionType(HttpResponseException.class)
+ Response createSync(@HostParam("endpoint") String endpoint,
+ @PathParam("operationRoute") String operationRoute, @HeaderParam("Content-Type") String contentType,
+ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData createRequest,
+ RequestOptions requestOptions, Context context);
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * delta (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Optional)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Optional)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createStreamingRequest The createStreamingRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return a single response to a streaming completion request along with {@link Response} on successful completion
+ * of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createStreamingWithResponseAsync(String operationRoute,
+ BinaryData createStreamingRequest, RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.createStreaming(this.client.getEndpoint(), operationRoute,
+ contentType, accept, createStreamingRequest, requestOptions, context));
+ }
+
+ /**
+ * Creates a new streaming chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * delta (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Optional)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Optional)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createStreamingRequest The createStreamingRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return a single response to a streaming completion request along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createStreamingWithResponse(String operationRoute, BinaryData createStreamingRequest,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.createStreamingSync(this.client.getEndpoint(), operationRoute, contentType, accept,
+ createStreamingRequest, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Creates a new chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * message (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Required)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createRequest The createRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return representation of the response to a chat completion request along with {@link Response} on successful
+ * completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createWithResponseAsync(String operationRoute, BinaryData createRequest,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.create(this.client.getEndpoint(), operationRoute, contentType,
+ accept, createRequest, requestOptions, context));
+ }
+
+ /**
+ * Creates a new chat completion.
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * messages (Required): [
+ * (Required){
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * ]
+ * stream: boolean (Required)
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * choices (Required): [
+ * (Required){
+ * index: long (Required)
+ * message (Required): {
+ * kind: String(text) (Required)
+ * role: String(user/system/assistant) (Required)
+ * sessionState: BinaryData (Optional)
+ * }
+ * sessionState: BinaryData (Optional)
+ * context (Optional): {
+ * String: BinaryData (Required)
+ * }
+ * finishReason: String(stop/length) (Required)
+ * }
+ * ]
+ * }
+ * }
+ *
+ *
+ * @param operationRoute The route where the endpoint exposes the chat operations.
+ * @param createRequest The createRequest parameter.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return representation of the response to a chat completion request along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createWithResponse(String operationRoute, BinaryData createRequest,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.createSync(this.client.getEndpoint(), operationRoute, contentType, accept, createRequest,
+ requestOptions, Context.NONE);
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/CreateRequest.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/CreateRequest.java
new file mode 100644
index 000000000000..603a36190b7d
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/CreateRequest.java
@@ -0,0 +1,194 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.implementation.models;
+
+import com.azure.ai.chatprotocol.models.ChatMessage;
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The CreateRequest model.
+ */
+@Fluent
+public final class CreateRequest implements JsonSerializable {
+ /*
+ * The collection of context messages associated with this completion request.
+ */
+ @Generated
+ private final List messages;
+
+ /*
+ * Indicates whether the completion is a streaming or non-streaming completion.
+ */
+ @Generated
+ private final boolean stream = false;
+
+ /*
+ * Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ */
+ @Generated
+ private BinaryData sessionState;
+
+ /*
+ * Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ */
+ @Generated
+ private Map context;
+
+ /**
+ * Creates an instance of CreateRequest class.
+ *
+ * @param messages the messages value to set.
+ */
+ @Generated
+ public CreateRequest(List messages) {
+ this.messages = messages;
+ }
+
+ /**
+ * Get the messages property: The collection of context messages associated with this completion request.
+ *
+ * @return the messages value.
+ */
+ @Generated
+ public List getMessages() {
+ return this.messages;
+ }
+
+ /**
+ * Get the stream property: Indicates whether the completion is a streaming or non-streaming completion.
+ *
+ * @return the stream value.
+ */
+ @Generated
+ public boolean isStream() {
+ return this.stream;
+ }
+
+ /**
+ * Get the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @return the sessionState value.
+ */
+ @Generated
+ public BinaryData getSessionState() {
+ return this.sessionState;
+ }
+
+ /**
+ * Set the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @param sessionState the sessionState value to set.
+ * @return the CreateRequest object itself.
+ */
+ @Generated
+ public CreateRequest setSessionState(BinaryData sessionState) {
+ this.sessionState = sessionState;
+ return this;
+ }
+
+ /**
+ * Get the context property: Context allows the chat app to receive extra parameters from the client, such as
+ * temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ *
+ * @return the context value.
+ */
+ @Generated
+ public Map getContext() {
+ return this.context;
+ }
+
+ /**
+ * Set the context property: Context allows the chat app to receive extra parameters from the client, such as
+ * temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ *
+ * @param context the context value to set.
+ * @return the CreateRequest object itself.
+ */
+ @Generated
+ public CreateRequest setContext(Map context) {
+ this.context = context;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeArrayField("messages", this.messages, (writer, element) -> writer.writeJson(element));
+ jsonWriter.writeBooleanField("stream", this.stream);
+ if (this.sessionState != null) {
+ jsonWriter.writeFieldName("sessionState");
+ this.sessionState.writeTo(jsonWriter);
+ }
+ jsonWriter.writeMapField("context", this.context,
+ (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class)));
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of CreateRequest from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of CreateRequest if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the CreateRequest.
+ */
+ @Generated
+ public static CreateRequest fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ List messages = null;
+ BinaryData sessionState = null;
+ Map context = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("messages".equals(fieldName)) {
+ messages = reader.readArray(reader1 -> ChatMessage.fromJson(reader1));
+ } else if ("sessionState".equals(fieldName)) {
+ sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else if ("context".equals(fieldName)) {
+ context = reader.readMap(reader1 -> reader1
+ .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())));
+ } else {
+ reader.skipChildren();
+ }
+ }
+ CreateRequest deserializedCreateRequest = new CreateRequest(messages);
+ deserializedCreateRequest.sessionState = sessionState;
+ deserializedCreateRequest.context = context;
+
+ return deserializedCreateRequest;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/CreateStreamingRequest.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/CreateStreamingRequest.java
new file mode 100644
index 000000000000..eba2bd10f9d4
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/CreateStreamingRequest.java
@@ -0,0 +1,194 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.implementation.models;
+
+import com.azure.ai.chatprotocol.models.ChatMessage;
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The CreateStreamingRequest model.
+ */
+@Fluent
+public final class CreateStreamingRequest implements JsonSerializable {
+ /*
+ * The collection of context messages associated with this completion request.
+ */
+ @Generated
+ private final List messages;
+
+ /*
+ * Indicates whether the completion is a streaming or non-streaming completion.
+ */
+ @Generated
+ private final boolean stream = true;
+
+ /*
+ * Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ */
+ @Generated
+ private BinaryData sessionState;
+
+ /*
+ * Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ */
+ @Generated
+ private Map context;
+
+ /**
+ * Creates an instance of CreateStreamingRequest class.
+ *
+ * @param messages the messages value to set.
+ */
+ @Generated
+ public CreateStreamingRequest(List messages) {
+ this.messages = messages;
+ }
+
+ /**
+ * Get the messages property: The collection of context messages associated with this completion request.
+ *
+ * @return the messages value.
+ */
+ @Generated
+ public List getMessages() {
+ return this.messages;
+ }
+
+ /**
+ * Get the stream property: Indicates whether the completion is a streaming or non-streaming completion.
+ *
+ * @return the stream value.
+ */
+ @Generated
+ public boolean isStream() {
+ return this.stream;
+ }
+
+ /**
+ * Get the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @return the sessionState value.
+ */
+ @Generated
+ public BinaryData getSessionState() {
+ return this.sessionState;
+ }
+
+ /**
+ * Set the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @param sessionState the sessionState value to set.
+ * @return the CreateStreamingRequest object itself.
+ */
+ @Generated
+ public CreateStreamingRequest setSessionState(BinaryData sessionState) {
+ this.sessionState = sessionState;
+ return this;
+ }
+
+ /**
+ * Get the context property: Context allows the chat app to receive extra parameters from the client, such as
+ * temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ *
+ * @return the context value.
+ */
+ @Generated
+ public Map getContext() {
+ return this.context;
+ }
+
+ /**
+ * Set the context property: Context allows the chat app to receive extra parameters from the client, such as
+ * temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ *
+ * @param context the context value to set.
+ * @return the CreateStreamingRequest object itself.
+ */
+ @Generated
+ public CreateStreamingRequest setContext(Map context) {
+ this.context = context;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeArrayField("messages", this.messages, (writer, element) -> writer.writeJson(element));
+ jsonWriter.writeBooleanField("stream", this.stream);
+ if (this.sessionState != null) {
+ jsonWriter.writeFieldName("sessionState");
+ this.sessionState.writeTo(jsonWriter);
+ }
+ jsonWriter.writeMapField("context", this.context,
+ (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class)));
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of CreateStreamingRequest from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of CreateStreamingRequest if the JsonReader was pointing to an instance of it, or null if it
+ * was pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the CreateStreamingRequest.
+ */
+ @Generated
+ public static CreateStreamingRequest fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ List messages = null;
+ BinaryData sessionState = null;
+ Map context = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("messages".equals(fieldName)) {
+ messages = reader.readArray(reader1 -> ChatMessage.fromJson(reader1));
+ } else if ("sessionState".equals(fieldName)) {
+ sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else if ("context".equals(fieldName)) {
+ context = reader.readMap(reader1 -> reader1
+ .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())));
+ } else {
+ reader.skipChildren();
+ }
+ }
+ CreateStreamingRequest deserializedCreateStreamingRequest = new CreateStreamingRequest(messages);
+ deserializedCreateStreamingRequest.sessionState = sessionState;
+ deserializedCreateStreamingRequest.context = context;
+
+ return deserializedCreateStreamingRequest;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/package-info.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/package-info.java
new file mode 100644
index 000000000000..02b80536e039
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/models/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the data models for ChatProtocol.
+ * Azure APIs for the Azure Chat protocol.
+ */
+package com.azure.ai.chatprotocol.implementation.models;
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/package-info.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/package-info.java
new file mode 100644
index 000000000000..580c80d3be69
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/implementation/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the implementations for ChatProtocol.
+ * Azure APIs for the Azure Chat protocol.
+ */
+package com.azure.ai.chatprotocol.implementation;
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatChoice.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatChoice.java
new file mode 100644
index 000000000000..101c17cd77b6
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatChoice.java
@@ -0,0 +1,190 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * The representation of a single generated completion.
+ */
+@Immutable
+public final class ChatChoice implements JsonSerializable {
+ /*
+ * The index of the of the chat choice, relative to the other choices in the same completion.
+ */
+ @Generated
+ private final long index;
+
+ /*
+ * The chat message for a given chat completion.
+ */
+ @Generated
+ private final ChatMessage message;
+
+ /*
+ * Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ */
+ @Generated
+ private BinaryData sessionState;
+
+ /*
+ * Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ */
+ @Generated
+ private Map context;
+
+ /*
+ * The reason this chat completion completed its generation.
+ */
+ @Generated
+ private final FinishReason finishReason;
+
+ /**
+ * Creates an instance of ChatChoice class.
+ *
+ * @param index the index value to set.
+ * @param message the message value to set.
+ * @param finishReason the finishReason value to set.
+ */
+ @Generated
+ private ChatChoice(long index, ChatMessage message, FinishReason finishReason) {
+ this.index = index;
+ this.message = message;
+ this.finishReason = finishReason;
+ }
+
+ /**
+ * Get the index property: The index of the of the chat choice, relative to the other choices in the same
+ * completion.
+ *
+ * @return the index value.
+ */
+ @Generated
+ public long getIndex() {
+ return this.index;
+ }
+
+ /**
+ * Get the message property: The chat message for a given chat completion.
+ *
+ * @return the message value.
+ */
+ @Generated
+ public ChatMessage getMessage() {
+ return this.message;
+ }
+
+ /**
+ * Get the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @return the sessionState value.
+ */
+ @Generated
+ public BinaryData getSessionState() {
+ return this.sessionState;
+ }
+
+ /**
+ * Get the context property: Context allows the chat app to receive extra parameters from the client, such as
+ * temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ *
+ * @return the context value.
+ */
+ @Generated
+ public Map getContext() {
+ return this.context;
+ }
+
+ /**
+ * Get the finishReason property: The reason this chat completion completed its generation.
+ *
+ * @return the finishReason value.
+ */
+ @Generated
+ public FinishReason getFinishReason() {
+ return this.finishReason;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeLongField("index", this.index);
+ jsonWriter.writeJsonField("message", this.message);
+ jsonWriter.writeStringField("finishReason", this.finishReason == null ? null : this.finishReason.toString());
+ if (this.sessionState != null) {
+ jsonWriter.writeFieldName("sessionState");
+ this.sessionState.writeTo(jsonWriter);
+ }
+ jsonWriter.writeMapField("context", this.context,
+ (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class)));
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatChoice from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatChoice if the JsonReader was pointing to an instance of it, or null if it was pointing
+ * to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatChoice.
+ */
+ @Generated
+ public static ChatChoice fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ long index = 0L;
+ ChatMessage message = null;
+ FinishReason finishReason = null;
+ BinaryData sessionState = null;
+ Map context = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("index".equals(fieldName)) {
+ index = reader.getLong();
+ } else if ("message".equals(fieldName)) {
+ message = ChatMessage.fromJson(reader);
+ } else if ("finishReason".equals(fieldName)) {
+ finishReason = FinishReason.fromString(reader.getString());
+ } else if ("sessionState".equals(fieldName)) {
+ sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else if ("context".equals(fieldName)) {
+ context = reader.readMap(reader1 -> reader1
+ .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())));
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatChoice deserializedChatChoice = new ChatChoice(index, message, finishReason);
+ deserializedChatChoice.sessionState = sessionState;
+ deserializedChatChoice.context = context;
+
+ return deserializedChatChoice;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatCompletion.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatCompletion.java
new file mode 100644
index 000000000000..70649f4e1be4
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatCompletion.java
@@ -0,0 +1,84 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Representation of the response to a chat completion request.
+ */
+@Immutable
+public final class ChatCompletion implements JsonSerializable {
+ /*
+ * The collection of generated completions.
+ */
+ @Generated
+ private final List choices;
+
+ /**
+ * Creates an instance of ChatCompletion class.
+ *
+ * @param choices the choices value to set.
+ */
+ @Generated
+ private ChatCompletion(List choices) {
+ this.choices = choices;
+ }
+
+ /**
+ * Get the choices property: The collection of generated completions.
+ *
+ * @return the choices value.
+ */
+ @Generated
+ public List getChoices() {
+ return this.choices;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeArrayField("choices", this.choices, (writer, element) -> writer.writeJson(element));
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatCompletion from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatCompletion if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatCompletion.
+ */
+ @Generated
+ public static ChatCompletion fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ List choices = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("choices".equals(fieldName)) {
+ choices = reader.readArray(reader1 -> ChatChoice.fromJson(reader1));
+ } else {
+ reader.skipChildren();
+ }
+ }
+ return new ChatCompletion(choices);
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatCompletionChunk.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatCompletionChunk.java
new file mode 100644
index 000000000000..d3b2e6a701fa
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatCompletionChunk.java
@@ -0,0 +1,84 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A single response to a streaming completion request.
+ */
+@Immutable
+public final class ChatCompletionChunk implements JsonSerializable {
+ /*
+ * The collection of choice deltas received in this chunk.
+ */
+ @Generated
+ private final List choices;
+
+ /**
+ * Creates an instance of ChatCompletionChunk class.
+ *
+ * @param choices the choices value to set.
+ */
+ @Generated
+ private ChatCompletionChunk(List choices) {
+ this.choices = choices;
+ }
+
+ /**
+ * Get the choices property: The collection of choice deltas received in this chunk.
+ *
+ * @return the choices value.
+ */
+ @Generated
+ public List getChoices() {
+ return this.choices;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeArrayField("choices", this.choices, (writer, element) -> writer.writeJson(element));
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatCompletionChunk from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatCompletionChunk if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatCompletionChunk.
+ */
+ @Generated
+ public static ChatCompletionChunk fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ List choices = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("choices".equals(fieldName)) {
+ choices = reader.readArray(reader1 -> ChoiceDelta.fromJson(reader1));
+ } else {
+ reader.skipChildren();
+ }
+ }
+ return new ChatCompletionChunk(choices);
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatMessage.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatMessage.java
new file mode 100644
index 000000000000..250c834dd8fc
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatMessage.java
@@ -0,0 +1,181 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * A single, role-attributed message within a chat completion interaction.
+ */
+@Fluent
+public class ChatMessage implements JsonSerializable {
+ /*
+ * The type of the message. If not specified, the message is assumed to be text.
+ */
+ @Generated
+ private MessageKind kind = MessageKind.fromString("ChatMessage");
+
+ /*
+ * The role associated with the message.
+ */
+ @Generated
+ private final ChatRole role;
+
+ /*
+ * Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ */
+ @Generated
+ private BinaryData sessionState;
+
+ /**
+ * Creates an instance of ChatMessage class.
+ *
+ * @param role the role value to set.
+ */
+ @Generated
+ public ChatMessage(ChatRole role) {
+ this.role = role;
+ }
+
+ /**
+ * Get the kind property: The type of the message. If not specified, the message is assumed to be text.
+ *
+ * @return the kind value.
+ */
+ @Generated
+ public MessageKind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * Get the role property: The role associated with the message.
+ *
+ * @return the role value.
+ */
+ @Generated
+ public ChatRole getRole() {
+ return this.role;
+ }
+
+ /**
+ * Get the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @return the sessionState value.
+ */
+ @Generated
+ public BinaryData getSessionState() {
+ return this.sessionState;
+ }
+
+ /**
+ * Set the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @param sessionState the sessionState value to set.
+ * @return the ChatMessage object itself.
+ */
+ @Generated
+ public ChatMessage setSessionState(BinaryData sessionState) {
+ this.sessionState = sessionState;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString());
+ jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+ if (this.sessionState != null) {
+ jsonWriter.writeFieldName("sessionState");
+ this.sessionState.writeTo(jsonWriter);
+ }
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatMessage from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatMessage if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatMessage.
+ */
+ @Generated
+ public static ChatMessage fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String discriminatorValue = null;
+ try (JsonReader readerToUse = reader.bufferObject()) {
+ readerToUse.nextToken(); // Prepare for reading
+ while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = readerToUse.getFieldName();
+ readerToUse.nextToken();
+ if ("kind".equals(fieldName)) {
+ discriminatorValue = readerToUse.getString();
+ break;
+ } else {
+ readerToUse.skipChildren();
+ }
+ }
+ // Use the discriminator value to determine which subtype should be deserialized.
+ if ("text".equals(discriminatorValue)) {
+ return TextChatMessage.fromJson(readerToUse.reset());
+ } else {
+ return fromJsonKnownDiscriminator(readerToUse.reset());
+ }
+ }
+ });
+ }
+
+ @Generated
+ static ChatMessage fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ ChatRole role = null;
+ MessageKind kind = null;
+ BinaryData sessionState = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("role".equals(fieldName)) {
+ role = ChatRole.fromString(reader.getString());
+ } else if ("kind".equals(fieldName)) {
+ kind = MessageKind.fromString(reader.getString());
+ } else if ("sessionState".equals(fieldName)) {
+ sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatMessage deserializedChatMessage = new ChatMessage(role);
+ deserializedChatMessage.kind = kind;
+ deserializedChatMessage.sessionState = sessionState;
+
+ return deserializedChatMessage;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatMessageDelta.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatMessageDelta.java
new file mode 100644
index 000000000000..cc5570cc0f53
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatMessageDelta.java
@@ -0,0 +1,184 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * The representation of a delta message received in a streaming completion.
+ */
+@Immutable
+public class ChatMessageDelta implements JsonSerializable {
+ /*
+ * The type of the message. If not specified, the message is assumed to be text.
+ */
+ @Generated
+ private MessageKind kind = MessageKind.fromString("ChatMessageDelta");
+
+ /*
+ * The role associated with the message.
+ */
+ @Generated
+ private ChatRole role;
+
+ /*
+ * Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ */
+ @Generated
+ private BinaryData sessionState;
+
+ /**
+ * Creates an instance of ChatMessageDelta class.
+ */
+ @Generated
+ protected ChatMessageDelta() {
+ }
+
+ /**
+ * Get the kind property: The type of the message. If not specified, the message is assumed to be text.
+ *
+ * @return the kind value.
+ */
+ @Generated
+ public MessageKind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * Get the role property: The role associated with the message.
+ *
+ * @return the role value.
+ */
+ @Generated
+ public ChatRole getRole() {
+ return this.role;
+ }
+
+ /**
+ * Set the role property: The role associated with the message.
+ *
+ * @param role the role value to set.
+ * @return the ChatMessageDelta object itself.
+ */
+ @Generated
+ ChatMessageDelta setRole(ChatRole role) {
+ this.role = role;
+ return this;
+ }
+
+ /**
+ * Get the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @return the sessionState value.
+ */
+ @Generated
+ public BinaryData getSessionState() {
+ return this.sessionState;
+ }
+
+ /**
+ * Set the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @param sessionState the sessionState value to set.
+ * @return the ChatMessageDelta object itself.
+ */
+ @Generated
+ ChatMessageDelta setSessionState(BinaryData sessionState) {
+ this.sessionState = sessionState;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+ jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString());
+ if (this.sessionState != null) {
+ jsonWriter.writeFieldName("sessionState");
+ this.sessionState.writeTo(jsonWriter);
+ }
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatMessageDelta from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatMessageDelta if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IOException If an error occurs while reading the ChatMessageDelta.
+ */
+ @Generated
+ public static ChatMessageDelta fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String discriminatorValue = null;
+ try (JsonReader readerToUse = reader.bufferObject()) {
+ readerToUse.nextToken(); // Prepare for reading
+ while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = readerToUse.getFieldName();
+ readerToUse.nextToken();
+ if ("kind".equals(fieldName)) {
+ discriminatorValue = readerToUse.getString();
+ break;
+ } else {
+ readerToUse.skipChildren();
+ }
+ }
+ // Use the discriminator value to determine which subtype should be deserialized.
+ if ("text".equals(discriminatorValue)) {
+ return TextChatMessageDelta.fromJson(readerToUse.reset());
+ } else {
+ return fromJsonKnownDiscriminator(readerToUse.reset());
+ }
+ }
+ });
+ }
+
+ @Generated
+ static ChatMessageDelta fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ ChatMessageDelta deserializedChatMessageDelta = new ChatMessageDelta();
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("kind".equals(fieldName)) {
+ deserializedChatMessageDelta.kind = MessageKind.fromString(reader.getString());
+ } else if ("role".equals(fieldName)) {
+ deserializedChatMessageDelta.role = ChatRole.fromString(reader.getString());
+ } else if ("sessionState".equals(fieldName)) {
+ deserializedChatMessageDelta.sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else {
+ reader.skipChildren();
+ }
+ }
+
+ return deserializedChatMessageDelta;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatRole.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatRole.java
new file mode 100644
index 000000000000..7940db37998f
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChatRole.java
@@ -0,0 +1,63 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.ExpandableStringEnum;
+import java.util.Collection;
+
+/**
+ * A representation of the intended purpose of a message.
+ */
+public final class ChatRole extends ExpandableStringEnum {
+ /**
+ * The role that provides input to the completion.
+ */
+ @Generated
+ public static final ChatRole USER = fromString("user");
+
+ /**
+ * The role that instructs or configures the behavior of the assistant.
+ */
+ @Generated
+ public static final ChatRole SYSTEM = fromString("system");
+
+ /**
+ * The role that provides responses to the system-instructed, user-prompted input.
+ */
+ @Generated
+ public static final ChatRole ASSISTANT = fromString("assistant");
+
+ /**
+ * Creates a new instance of ChatRole value.
+ *
+ * @deprecated Use the {@link #fromString(String)} factory method.
+ */
+ @Generated
+ @Deprecated
+ public ChatRole() {
+ }
+
+ /**
+ * Creates or finds a ChatRole from its string representation.
+ *
+ * @param name a name to look for.
+ * @return the corresponding ChatRole.
+ */
+ @Generated
+ public static ChatRole fromString(String name) {
+ return fromString(name, ChatRole.class);
+ }
+
+ /**
+ * Gets known ChatRole values.
+ *
+ * @return known ChatRole values.
+ */
+ @Generated
+ public static Collection values() {
+ return values(ChatRole.class);
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChoiceDelta.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChoiceDelta.java
new file mode 100644
index 000000000000..7e2b5b0609c7
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/ChoiceDelta.java
@@ -0,0 +1,189 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * The representation of an incremental choice received in a streaming completion.
+ */
+@Immutable
+public final class ChoiceDelta implements JsonSerializable {
+ /*
+ * The index of the of the chat choice, relative to the other choices in the same completion.
+ */
+ @Generated
+ private final long index;
+
+ /*
+ * The partial message received for this choice.
+ */
+ @Generated
+ private final ChatMessageDelta delta;
+
+ /*
+ * Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ */
+ @Generated
+ private BinaryData sessionState;
+
+ /*
+ * Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ */
+ @Generated
+ private Map context;
+
+ /*
+ * The reason this chat completion completed its generation.
+ */
+ @Generated
+ private FinishReason finishReason;
+
+ /**
+ * Creates an instance of ChoiceDelta class.
+ *
+ * @param index the index value to set.
+ * @param delta the delta value to set.
+ */
+ @Generated
+ private ChoiceDelta(long index, ChatMessageDelta delta) {
+ this.index = index;
+ this.delta = delta;
+ }
+
+ /**
+ * Get the index property: The index of the of the chat choice, relative to the other choices in the same
+ * completion.
+ *
+ * @return the index value.
+ */
+ @Generated
+ public long getIndex() {
+ return this.index;
+ }
+
+ /**
+ * Get the delta property: The partial message received for this choice.
+ *
+ * @return the delta value.
+ */
+ @Generated
+ public ChatMessageDelta getDelta() {
+ return this.delta;
+ }
+
+ /**
+ * Get the sessionState property: Field that allows the chat app to store and retrieve data, the structure of such
+ * data is dependant on the backend
+ * being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app
+ * sends a new one. The data in this field can be used to implement stateful services, such as remembering previous
+ * conversations or user preferences.
+ *
+ * @return the sessionState value.
+ */
+ @Generated
+ public BinaryData getSessionState() {
+ return this.sessionState;
+ }
+
+ /**
+ * Get the context property: Context allows the chat app to receive extra parameters from the client, such as
+ * temperature, functions, or
+ * customer_info. These parameters are specific to the chat app and not understood by the generic clients.
+ *
+ * @return the context value.
+ */
+ @Generated
+ public Map getContext() {
+ return this.context;
+ }
+
+ /**
+ * Get the finishReason property: The reason this chat completion completed its generation.
+ *
+ * @return the finishReason value.
+ */
+ @Generated
+ public FinishReason getFinishReason() {
+ return this.finishReason;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeLongField("index", this.index);
+ jsonWriter.writeJsonField("delta", this.delta);
+ if (this.sessionState != null) {
+ jsonWriter.writeFieldName("sessionState");
+ this.sessionState.writeTo(jsonWriter);
+ }
+ jsonWriter.writeMapField("context", this.context,
+ (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class)));
+ jsonWriter.writeStringField("finishReason", this.finishReason == null ? null : this.finishReason.toString());
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChoiceDelta from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChoiceDelta if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChoiceDelta.
+ */
+ @Generated
+ public static ChoiceDelta fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ long index = 0L;
+ ChatMessageDelta delta = null;
+ BinaryData sessionState = null;
+ Map context = null;
+ FinishReason finishReason = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("index".equals(fieldName)) {
+ index = reader.getLong();
+ } else if ("delta".equals(fieldName)) {
+ delta = ChatMessageDelta.fromJson(reader);
+ } else if ("sessionState".equals(fieldName)) {
+ sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else if ("context".equals(fieldName)) {
+ context = reader.readMap(reader1 -> reader1
+ .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())));
+ } else if ("finishReason".equals(fieldName)) {
+ finishReason = FinishReason.fromString(reader.getString());
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChoiceDelta deserializedChoiceDelta = new ChoiceDelta(index, delta);
+ deserializedChoiceDelta.sessionState = sessionState;
+ deserializedChoiceDelta.context = context;
+ deserializedChoiceDelta.finishReason = finishReason;
+
+ return deserializedChoiceDelta;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/FinishReason.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/FinishReason.java
new file mode 100644
index 000000000000..2f07dc3eff13
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/FinishReason.java
@@ -0,0 +1,57 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.ExpandableStringEnum;
+import java.util.Collection;
+
+/**
+ * Representation of the reason why a chat session has finished processing.
+ */
+public final class FinishReason extends ExpandableStringEnum {
+ /**
+ * Completion ended normally.
+ */
+ @Generated
+ public static final FinishReason STOPPED = fromString("stop");
+
+ /**
+ * The completion exhausted available tokens before generation could complete.
+ */
+ @Generated
+ public static final FinishReason TOKEN_LIMIT_REACHED = fromString("length");
+
+ /**
+ * Creates a new instance of FinishReason value.
+ *
+ * @deprecated Use the {@link #fromString(String)} factory method.
+ */
+ @Generated
+ @Deprecated
+ public FinishReason() {
+ }
+
+ /**
+ * Creates or finds a FinishReason from its string representation.
+ *
+ * @param name a name to look for.
+ * @return the corresponding FinishReason.
+ */
+ @Generated
+ public static FinishReason fromString(String name) {
+ return fromString(name, FinishReason.class);
+ }
+
+ /**
+ * Gets known FinishReason values.
+ *
+ * @return known FinishReason values.
+ */
+ @Generated
+ public static Collection values() {
+ return values(FinishReason.class);
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/MessageKind.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/MessageKind.java
new file mode 100644
index 000000000000..53c24de7f088
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/MessageKind.java
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.ExpandableStringEnum;
+import java.util.Collection;
+
+/**
+ * Identifies the type of a message.
+ */
+public final class MessageKind extends ExpandableStringEnum {
+ /**
+ * The message context is text.
+ */
+ @Generated
+ public static final MessageKind TEXT = fromString("text");
+
+ /**
+ * Creates a new instance of MessageKind value.
+ *
+ * @deprecated Use the {@link #fromString(String)} factory method.
+ */
+ @Generated
+ @Deprecated
+ public MessageKind() {
+ }
+
+ /**
+ * Creates or finds a MessageKind from its string representation.
+ *
+ * @param name a name to look for.
+ * @return the corresponding MessageKind.
+ */
+ @Generated
+ public static MessageKind fromString(String name) {
+ return fromString(name, MessageKind.class);
+ }
+
+ /**
+ * Gets known MessageKind values.
+ *
+ * @return known MessageKind values.
+ */
+ @Generated
+ public static Collection values() {
+ return values(MessageKind.class);
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/TextChatMessage.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/TextChatMessage.java
new file mode 100644
index 000000000000..0946ae46677f
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/TextChatMessage.java
@@ -0,0 +1,132 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * A single, role-attributed text message within a chat completion interaction.
+ */
+@Fluent
+public final class TextChatMessage extends ChatMessage {
+ /*
+ * The type of the message. If not specified, the message is assumed to be text.
+ */
+ @Generated
+ private MessageKind kind = MessageKind.TEXT;
+
+ /*
+ * The text associated with the message.
+ */
+ @Generated
+ private final String content;
+
+ /**
+ * Creates an instance of TextChatMessage class.
+ *
+ * @param role the role value to set.
+ * @param content the content value to set.
+ */
+ @Generated
+ public TextChatMessage(ChatRole role, String content) {
+ super(role);
+ this.content = content;
+ }
+
+ /**
+ * Get the kind property: The type of the message. If not specified, the message is assumed to be text.
+ *
+ * @return the kind value.
+ */
+ @Generated
+ @Override
+ public MessageKind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * Get the content property: The text associated with the message.
+ *
+ * @return the content value.
+ */
+ @Generated
+ public String getContent() {
+ return this.content;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public TextChatMessage setSessionState(BinaryData sessionState) {
+ super.setSessionState(sessionState);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("role", getRole() == null ? null : getRole().toString());
+ if (getSessionState() != null) {
+ jsonWriter.writeFieldName("sessionState");
+ getSessionState().writeTo(jsonWriter);
+ }
+ jsonWriter.writeStringField("content", this.content);
+ jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of TextChatMessage from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of TextChatMessage if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the TextChatMessage.
+ */
+ @Generated
+ public static TextChatMessage fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ ChatRole role = null;
+ BinaryData sessionState = null;
+ String content = null;
+ MessageKind kind = MessageKind.TEXT;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("role".equals(fieldName)) {
+ role = ChatRole.fromString(reader.getString());
+ } else if ("sessionState".equals(fieldName)) {
+ sessionState
+ = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
+ } else if ("content".equals(fieldName)) {
+ content = reader.getString();
+ } else if ("kind".equals(fieldName)) {
+ kind = MessageKind.fromString(reader.getString());
+ } else {
+ reader.skipChildren();
+ }
+ }
+ TextChatMessage deserializedTextChatMessage = new TextChatMessage(role, content);
+ deserializedTextChatMessage.setSessionState(sessionState);
+ deserializedTextChatMessage.kind = kind;
+
+ return deserializedTextChatMessage;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/TextChatMessageDelta.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/TextChatMessageDelta.java
new file mode 100644
index 000000000000..53b6797d5af8
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/TextChatMessageDelta.java
@@ -0,0 +1,110 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.core.util.BinaryData;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * The representation of a delta text message received in a streaming completion.
+ */
+@Immutable
+public final class TextChatMessageDelta extends ChatMessageDelta {
+ /*
+ * The type of the message. If not specified, the message is assumed to be text.
+ */
+ @Generated
+ private MessageKind kind = MessageKind.TEXT;
+
+ /*
+ * An incremental part of the text associated with the message.
+ */
+ @Generated
+ private String content;
+
+ /**
+ * Creates an instance of TextChatMessageDelta class.
+ */
+ @Generated
+ private TextChatMessageDelta() {
+ }
+
+ /**
+ * Get the kind property: The type of the message. If not specified, the message is assumed to be text.
+ *
+ * @return the kind value.
+ */
+ @Generated
+ @Override
+ public MessageKind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * Get the content property: An incremental part of the text associated with the message.
+ *
+ * @return the content value.
+ */
+ @Generated
+ public String getContent() {
+ return this.content;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("role", getRole() == null ? null : getRole().toString());
+ if (getSessionState() != null) {
+ jsonWriter.writeFieldName("sessionState");
+ getSessionState().writeTo(jsonWriter);
+ }
+ jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+ jsonWriter.writeStringField("content", this.content);
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of TextChatMessageDelta from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of TextChatMessageDelta if the JsonReader was pointing to an instance of it, or null if it
+ * was pointing to JSON null.
+ * @throws IOException If an error occurs while reading the TextChatMessageDelta.
+ */
+ @Generated
+ public static TextChatMessageDelta fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ TextChatMessageDelta deserializedTextChatMessageDelta = new TextChatMessageDelta();
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("role".equals(fieldName)) {
+ deserializedTextChatMessageDelta.setRole(ChatRole.fromString(reader.getString()));
+ } else if ("sessionState".equals(fieldName)) {
+ deserializedTextChatMessageDelta.setSessionState(
+ reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())));
+ } else if ("kind".equals(fieldName)) {
+ deserializedTextChatMessageDelta.kind = MessageKind.fromString(reader.getString());
+ } else if ("content".equals(fieldName)) {
+ deserializedTextChatMessageDelta.content = reader.getString();
+ } else {
+ reader.skipChildren();
+ }
+ }
+
+ return deserializedTextChatMessageDelta;
+ });
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/package-info.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/package-info.java
new file mode 100644
index 000000000000..1c3c8e60d215
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/models/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the data models for ChatProtocol.
+ * Azure APIs for the Azure Chat protocol.
+ */
+package com.azure.ai.chatprotocol.models;
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/package-info.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/package-info.java
new file mode 100644
index 000000000000..bb7d9ba5ada4
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/com/azure/ai/chatprotocol/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the classes for ChatProtocol.
+ * Azure APIs for the Azure Chat protocol.
+ */
+package com.azure.ai.chatprotocol;
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/module-info.java b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/module-info.java
new file mode 100644
index 000000000000..0908242fc16b
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/java/module-info.java
@@ -0,0 +1,13 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+module com.azure.ai.chatprotocol {
+ requires transitive com.azure.core;
+
+ exports com.azure.ai.chatprotocol;
+ exports com.azure.ai.chatprotocol.models;
+
+ opens com.azure.ai.chatprotocol.models to com.azure.core;
+ opens com.azure.ai.chatprotocol.implementation.models to com.azure.core;
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/resources/META-INF/azure-ai-chatprotocol_apiview_properties.json b/sdk/machinelearning/azure-ai-chatprotocol/src/main/resources/META-INF/azure-ai-chatprotocol_apiview_properties.json
new file mode 100644
index 000000000000..f2a6bedd017a
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/resources/META-INF/azure-ai-chatprotocol_apiview_properties.json
@@ -0,0 +1,29 @@
+{
+ "flavor": "azure",
+ "CrossLanguageDefinitionId": {
+ "com.azure.ai.chatprotocol.ChatProtocolAsyncClient": "Azure.AI.ChatProtocol.Chat",
+ "com.azure.ai.chatprotocol.ChatProtocolAsyncClient.create": "Azure.AI.ChatProtocol.Chat.create",
+ "com.azure.ai.chatprotocol.ChatProtocolAsyncClient.createStreaming": "Azure.AI.ChatProtocol.Chat.createStreaming",
+ "com.azure.ai.chatprotocol.ChatProtocolAsyncClient.createStreamingWithResponse": "Azure.AI.ChatProtocol.Chat.createStreaming",
+ "com.azure.ai.chatprotocol.ChatProtocolAsyncClient.createWithResponse": "Azure.AI.ChatProtocol.Chat.create",
+ "com.azure.ai.chatprotocol.ChatProtocolClient": "Azure.AI.ChatProtocol.Chat",
+ "com.azure.ai.chatprotocol.ChatProtocolClient.create": "Azure.AI.ChatProtocol.Chat.create",
+ "com.azure.ai.chatprotocol.ChatProtocolClient.createStreaming": "Azure.AI.ChatProtocol.Chat.createStreaming",
+ "com.azure.ai.chatprotocol.ChatProtocolClient.createStreamingWithResponse": "Azure.AI.ChatProtocol.Chat.createStreaming",
+ "com.azure.ai.chatprotocol.ChatProtocolClient.createWithResponse": "Azure.AI.ChatProtocol.Chat.create",
+ "com.azure.ai.chatprotocol.ChatProtocolClientBuilder": "Azure.AI.ChatProtocol",
+ "com.azure.ai.chatprotocol.implementation.models.CreateRequest": "Azure.AI.ChatProtocol.create.Request.anonymous",
+ "com.azure.ai.chatprotocol.implementation.models.CreateStreamingRequest": "Azure.AI.ChatProtocol.createStreaming.Request.anonymous",
+ "com.azure.ai.chatprotocol.models.ChatChoice": "Azure.AI.ChatProtocol.ChatChoice",
+ "com.azure.ai.chatprotocol.models.ChatCompletion": "Azure.AI.ChatProtocol.ChatCompletion",
+ "com.azure.ai.chatprotocol.models.ChatCompletionChunk": "Azure.AI.ChatProtocol.ChatCompletionChunk",
+ "com.azure.ai.chatprotocol.models.ChatMessage": "Azure.AI.ChatProtocol.ChatMessage",
+ "com.azure.ai.chatprotocol.models.ChatMessageDelta": "Azure.AI.ChatProtocol.ChatMessageDelta",
+ "com.azure.ai.chatprotocol.models.ChatRole": "Azure.AI.ChatProtocol.ChatRole",
+ "com.azure.ai.chatprotocol.models.ChoiceDelta": "Azure.AI.ChatProtocol.ChoiceDelta",
+ "com.azure.ai.chatprotocol.models.FinishReason": "Azure.AI.ChatProtocol.FinishReason",
+ "com.azure.ai.chatprotocol.models.MessageKind": "Azure.AI.ChatProtocol.MessageKind",
+ "com.azure.ai.chatprotocol.models.TextChatMessage": "Azure.AI.ChatProtocol.TextChatMessage",
+ "com.azure.ai.chatprotocol.models.TextChatMessageDelta": "Azure.AI.ChatProtocol.TextChatMessageDelta"
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/main/resources/azure-ai-chatprotocol.properties b/sdk/machinelearning/azure-ai-chatprotocol/src/main/resources/azure-ai-chatprotocol.properties
new file mode 100644
index 000000000000..ca812989b4f2
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/main/resources/azure-ai-chatprotocol.properties
@@ -0,0 +1,2 @@
+name=${project.artifactId}
+version=${project.version}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/samples/java/com/azure/ai/chatprotocol/ReadmeSamples.java b/sdk/machinelearning/azure-ai-chatprotocol/src/samples/java/com/azure/ai/chatprotocol/ReadmeSamples.java
new file mode 100644
index 000000000000..7156111c7b70
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/samples/java/com/azure/ai/chatprotocol/ReadmeSamples.java
@@ -0,0 +1,12 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol;
+
+public final class ReadmeSamples {
+ public void readmeSamples() {
+ // BEGIN: com.azure.ai.chatprotocol.readme
+ // END: com.azure.ai.chatprotocol.readme
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/samples/java/com/azure/ai/chatprotocol/generated/CreatesAChatCompletionForTheProvidedPromptUsingStreaming.java b/sdk/machinelearning/azure-ai-chatprotocol/src/samples/java/com/azure/ai/chatprotocol/generated/CreatesAChatCompletionForTheProvidedPromptUsingStreaming.java
new file mode 100644
index 000000000000..9f2879accdec
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/samples/java/com/azure/ai/chatprotocol/generated/CreatesAChatCompletionForTheProvidedPromptUsingStreaming.java
@@ -0,0 +1,40 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.generated;
+
+import com.azure.ai.chatprotocol.ChatProtocolClient;
+import com.azure.ai.chatprotocol.ChatProtocolClientBuilder;
+import com.azure.ai.chatprotocol.models.ChatCompletionChunk;
+import com.azure.ai.chatprotocol.models.ChatRole;
+import com.azure.ai.chatprotocol.models.TextChatMessage;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CreatesAChatCompletionForTheProvidedPromptUsingStreaming {
+ public static void main(String[] args) {
+ ChatProtocolClient chatProtocolClient
+ = new ChatProtocolClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
+ .endpoint("{endpoint}")
+ .buildClient();
+ // BEGIN:com.azure.ai.chatprotocol.generated.chatcreatestreaming.createsachatcompletionfortheprovidedpromptusingstreaming
+ ChatCompletionChunk response = chatProtocolClient.createStreaming("chat",
+ Arrays.asList(new TextChatMessage(ChatRole.USER, "Tell me a joke")), null, mapOf());
+ // END:com.azure.ai.chatprotocol.generated.chatcreatestreaming.createsachatcompletionfortheprovidedpromptusingstreaming
+ }
+
+ // Use "Map.of" if available
+ @SuppressWarnings("unchecked")
+ private static Map mapOf(Object... inputs) {
+ Map map = new HashMap<>();
+ for (int i = 0; i < inputs.length; i += 2) {
+ String key = (String) inputs[i];
+ T value = (T) inputs[i + 1];
+ map.put(key, value);
+ }
+ return map;
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/test/java/com/azure/ai/chatprotocol/generated/ChatProtocolClientTestBase.java b/sdk/machinelearning/azure-ai-chatprotocol/src/test/java/com/azure/ai/chatprotocol/generated/ChatProtocolClientTestBase.java
new file mode 100644
index 000000000000..84f6e87c4d0d
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/test/java/com/azure/ai/chatprotocol/generated/ChatProtocolClientTestBase.java
@@ -0,0 +1,41 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.generated;
+
+// The Java test files under 'generated' package are generated for your reference.
+// If you wish to modify these files, please copy them out of the 'generated' package, and modify there.
+// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test.
+
+import com.azure.ai.chatprotocol.ChatProtocolClient;
+import com.azure.ai.chatprotocol.ChatProtocolClientBuilder;
+import com.azure.core.http.policy.HttpLogDetailLevel;
+import com.azure.core.http.policy.HttpLogOptions;
+import com.azure.core.test.TestMode;
+import com.azure.core.test.TestProxyTestBase;
+import com.azure.core.test.utils.MockTokenCredential;
+import com.azure.core.util.Configuration;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+
+class ChatProtocolClientTestBase extends TestProxyTestBase {
+ protected ChatProtocolClient chatProtocolClient;
+
+ @Override
+ protected void beforeTest() {
+ ChatProtocolClientBuilder chatProtocolClientbuilder = new ChatProtocolClientBuilder()
+ .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint"))
+ .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null)))
+ .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
+ if (getTestMode() == TestMode.PLAYBACK) {
+ chatProtocolClientbuilder.credential(new MockTokenCredential());
+ } else if (getTestMode() == TestMode.RECORD) {
+ chatProtocolClientbuilder.addPolicy(interceptorManager.getRecordPolicy())
+ .credential(new DefaultAzureCredentialBuilder().build());
+ } else if (getTestMode() == TestMode.LIVE) {
+ chatProtocolClientbuilder.credential(new DefaultAzureCredentialBuilder().build());
+ }
+ chatProtocolClient = chatProtocolClientbuilder.buildClient();
+
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/src/test/java/com/azure/ai/chatprotocol/generated/CreatesAChatCompletionForTheProvidedPromptUsingStreamingTests.java b/sdk/machinelearning/azure-ai-chatprotocol/src/test/java/com/azure/ai/chatprotocol/generated/CreatesAChatCompletionForTheProvidedPromptUsingStreamingTests.java
new file mode 100644
index 000000000000..764090429016
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/src/test/java/com/azure/ai/chatprotocol/generated/CreatesAChatCompletionForTheProvidedPromptUsingStreamingTests.java
@@ -0,0 +1,59 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.ai.chatprotocol.generated;
+
+import com.azure.ai.chatprotocol.models.ChatCompletionChunk;
+import com.azure.ai.chatprotocol.models.ChatMessageDelta;
+import com.azure.ai.chatprotocol.models.ChatRole;
+import com.azure.ai.chatprotocol.models.ChoiceDelta;
+import com.azure.ai.chatprotocol.models.FinishReason;
+import com.azure.ai.chatprotocol.models.MessageKind;
+import com.azure.ai.chatprotocol.models.TextChatMessage;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+@Disabled
+public final class CreatesAChatCompletionForTheProvidedPromptUsingStreamingTests extends ChatProtocolClientTestBase {
+ @Test
+ @Disabled
+ public void testCreatesAChatCompletionForTheProvidedPromptUsingStreamingTests() {
+ // method invocation
+ ChatCompletionChunk response = chatProtocolClient.createStreaming("chat",
+ Arrays.asList(new TextChatMessage(ChatRole.USER, "Tell me a joke")), null, mapOf());
+
+ // response assertion
+ Assertions.assertNotNull(response);
+ // verify property "choices"
+ List responseChoices = response.getChoices();
+ ChoiceDelta responseChoicesFirstItem = responseChoices.iterator().next();
+ Assertions.assertNotNull(responseChoicesFirstItem);
+ Assertions.assertEquals(0L, responseChoicesFirstItem.getIndex());
+ ChatMessageDelta responseChoicesFirstItemDelta = responseChoicesFirstItem.getDelta();
+ Assertions.assertNotNull(responseChoicesFirstItemDelta);
+ Assertions.assertEquals(MessageKind.TEXT, responseChoicesFirstItemDelta.getKind());
+ Assertions.assertEquals(ChatRole.ASSISTANT, responseChoicesFirstItemDelta.getRole());
+ Assertions.assertNotNull(responseChoicesFirstItemDelta.getSessionState());
+ Assertions.assertNotNull(responseChoicesFirstItem.getSessionState());
+ Assertions.assertNotNull(responseChoicesFirstItem.getContext());
+ Assertions.assertEquals(FinishReason.STOPPED, responseChoicesFirstItem.getFinishReason());
+ }
+
+ // Use "Map.of" if available
+ @SuppressWarnings("unchecked")
+ private static Map mapOf(Object... inputs) {
+ Map map = new HashMap<>();
+ for (int i = 0; i < inputs.length; i += 2) {
+ String key = (String) inputs[i];
+ T value = (T) inputs[i + 1];
+ map.put(key, value);
+ }
+ return map;
+ }
+}
diff --git a/sdk/machinelearning/azure-ai-chatprotocol/tsp-location.yaml b/sdk/machinelearning/azure-ai-chatprotocol/tsp-location.yaml
new file mode 100644
index 000000000000..102911b500d2
--- /dev/null
+++ b/sdk/machinelearning/azure-ai-chatprotocol/tsp-location.yaml
@@ -0,0 +1,4 @@
+directory: specification/machinelearning/Azure.AI.ChatProtocol
+commit: 65ea9a38c20488eb047876e4207713aa4a392f82
+repo: Azure/azure-rest-api-specs
+additionalDirectories: