# 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 base request's messages are a fixed prefix: they lead every request, ahead of the conversation held by the view. That is what makes it the place for a system prompt, and it means anything else put there -- a seed user or assistant turn -- is repeated on every turn too, so put those in the view instead.

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, and its messages lead every request as described above.

- ## 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