You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rename features/capabilities to capabilities/options and simplify model discovery via AiModelRequirements objects that can be automatically inferred from message and config objects.
Copy file name to clipboardExpand all lines: docs/ARCHITECTURE.md
+69-41Lines changed: 69 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This document outlines the architecture for the PHP AI Client. It is critical th
6
6
7
7
The API design at a high level is heavily inspired by the [Vercel AI SDK](https://github.com/vercel/ai), which is widely used in the NodeJS ecosystem and one of the very few comprehensive AI client SDKs available.
8
8
9
-
The main additional aspect that the Vercel AI SDK does not cater for easily is for a developer to use AI in a way that the choice of provider remains with the user. To clarify with an example: Instead of "Generate text with Google's model `gemini-2.5-flash`", go with "Generate text using any provider model that supports text generation and multimodal input". In other words, there needs to be a mechanism that allows finding any configured model that supports the given set of required AI features and capabilities.
9
+
The main additional aspect that the Vercel AI SDK does not cater for easily is for a developer to use AI in a way that the choice of provider remains with the user. To clarify with an example: Instead of "Generate text with Google's model `gemini-2.5-flash`", go with "Generate text using any provider model that supports text generation and multimodal input". In other words, there needs to be a mechanism that allows finding any configured model that supports the given set of required AI capabilities and options.
#### Generate text with an image as additional input using any suitable model from any provider
93
93
94
-
_Note: Since this omits the model parameter, the SDK will automatically determine which models are suitable and use any of them, similar to [the first code example](#generate-text-using-any-suitable-model-from-any-provider-most-basic-example). Since it knows the input includes an image, it can internally infer that the model needs to not only support `AiFeature::TEXT_GENERATION`, but also `TextGenerationConfig::INPUT_MODALITIES => ['text', 'image']`._
94
+
_Note: Since this omits the model parameter, the SDK will automatically determine which models are suitable and use any of them, similar to [the first code example](#generate-text-using-any-suitable-model-from-any-provider-most-basic-example). Since it knows the input includes an image, it can internally infer that the model needs to not only support `AiCapability::TEXT_GENERATION`, but also `AiOption::INPUT_MODALITIES => ['text', 'image']`._
#### Generate text with chat history using any suitable model from any provider
111
111
112
-
_Note: Similarly to the previous example, even without specifying the model here, the SDK will be able to infer required model capabilities because it can detect that multiple chat messages are passed. Therefore it will internally only consider models that support `AiFeature::TEXT_GENERATION` as well as `TextGenerationConfig::CHAT_HISTORY`._
112
+
_Note: Similarly to the previous example, even without specifying the model here, the SDK will be able to infer required model capabilities because it can detect that multiple chat messages are passed. Therefore it will internally only consider models that support `AiCapability::TEXT_GENERATION` as well as `AiCapability::CHAT_HISTORY`._
113
113
114
114
```php
115
115
$text = Ai::generateTextResult(
@@ -136,11 +136,11 @@ _Note: Unlike the previous two examples, to require JSON output it is necessary
Copy file name to clipboardExpand all lines: docs/GLOSSARY.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@
3
3
This glossary defines common terms relevant for the PHP AI Client and related projects.
4
4
5
5
***Agent**: An autonomous system that can perceive its environment, make decisions, and take actions to achieve specific goals, often leveraging AI models.
6
+
***AI Capability**: A single string that denotes an AI feature, such as text generation or image generation.
7
+
***AI Option**: A parameter that can be passed to a model, such as temperature or output MIME type.
6
8
***Generative AI**: Overaching term describing AI models that generate content as requested in a prompt.
7
9
***MCP**: The "Model Context Protocol", a proposed standard for connecting AI assistants to the systems where data lives.
8
10
***Message**: A single message, either a user prompt, a model response, or a system prompt—optionally containing of multiple message parts.
0 commit comments