.. _creating-ai-connector: Creating an AI connector ======================== AI connectors integrate language model and embedding providers into AI Assistant. They are resolved through the AI connector registry by their identifier and are configured through AI connection records. Responsibilities ---------------- * expose a stable connector identifier; * accept an AI connection record; * create synchronous chat completions from ``AiRequest``; * stream chat completions to a callback; * create embeddings from ``EmbeddingRequest``; * create batch embeddings for multiple ``EmbeddingRequest`` objects; * map provider responses to ``AiResponse`` and ``EmbeddingResponse``; * preserve usage information where available; * keep provider-specific authentication and request mapping inside the connector. Identifier ---------- The identifier is stored in the AI connection record and is used by ``AiConnectorRegistry`` to resolve the service. .. code-block:: php public function getIdentifier(): string { return 'vendor.my_ai'; } Use a namespaced identifier to avoid collisions with other extensions. Skeleton -------- .. code-block:: php