# Class LlmChatBinding

java.lang.Object
com.codename1.ai.LlmChatBinding

public final class LlmChatBinding extends Object

Convenience wiring that turns a `ChatView` into an LLM-driven chat surface in one call. Pulls the user's input out of the view's `ChatInput`, appends it as a USER message, opens a streaming chat call against the supplied `LlmClient`, and pipes deltas into a freshly-appended assistant bubble.

`ChatView` itself has no dependency on the AI package, so apps that want a peer-to-peer messaging UI (a WhatsApp clone, for example) can keep using `ChatView` without pulling LlmClient onto their classpath -- it's only when you call `bind(ChatView, LlmClient, ChatRequest)` that the binding is established.

##### Example

    LlmClient client = LlmClient.openai(SecureStorage.getInstance().get("openai_key"));
    ChatRequest base = ChatRequest.builder()
            .model("gpt-4o-mini")
            .addMessage(ChatMessage.system("You are a terse assistant."))
            .build();
    ChatView view = new ChatView();
    LlmChatBinding.bind(view, client, base);
    // ...add view to a Form and that's it.

The view's accumulated history is replayed on every turn so the model has full conversation context. The original `baseRequest` is treated as a template -- its model, tools, temperature, etc. are preserved across turns; its messages are used only when the view's own history is empty (e.g. to seed a system prompt).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `bind(ChatView view, LlmClient client, ChatRequest baseRequest)`
  Connects a chat view to a streaming client.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### bind

    public static void bind(ChatView view, LlmClient client, ChatRequest baseRequest)
    Connects a chat view to a streaming client. Each submitted user message replays the current view history while retaining the base request's model, sampling, tool, metadata, and safety settings.
    Parameters:
      `view` - chat UI to drive
      `client` - provider client used for every turn
      `baseRequest` - request template and optional initial messages