# AI Provider for Together AI

AI Provider for Together AI for the [WordPress AI Client](https://github.com/WordPress/php-ai-client). Works as both a Composer package and a WordPress plugin.

This provider registers **Together AI** with the AI Client, exposing the open models served on Together AI (Llama, Qwen, DeepSeek, Mixtral, and more) for text generation through Together AI's OpenAI-compatible Chat Completions API.

## Requirements

- PHP 7.4+
- WordPress 6.9+ (when used as a plugin)
- The [`wordpress/php-ai-client`](https://github.com/WordPress/php-ai-client) SDK
- A Together AI API key from your [API keys](https://api.together.xyz/settings/api-keys) page

## How it works

Together AI exposes an OpenAI-compatible API, so this provider is intentionally thin:

| Class | Responsibility |
| --- | --- |
| `Provider\TogetherProvider` | Registers the provider, base URL (`https://api.together.xyz/v1`), API-key auth, and metadata. |
| `Metadata\TogetherModelMetadataDirectory` | Lists models from `GET /v1/models` and maps capabilities/options. |
| `Models\TogetherTextGenerationModel` | Sends `POST /v1/chat/completions` via the shared OpenAI-compatible base class. |

Because Together AI speaks the Chat Completions format, `TogetherTextGenerationModel` extends
`AbstractOpenAiCompatibleTextGenerationModel` from the SDK and only overrides request construction.

Together AI's `/v1/models` endpoint returns a bare list of models, each carrying a `type` and
a human-readable `display_name`. Only chat-capable models are exposed as text generators;
non-chat models (embeddings, moderation, rerank, image, audio, and base completion models)
are skipped. Models are listed alphabetically by display name, with multimodal (image) input
enabled for the vision-capable families.

## Supported capabilities

- Text generation (chat) with open models on Together AI
- Chat history / multi-turn conversations
- Multimodal (image) input for vision-capable models
- Function calling and JSON / structured output

## Installation

### As a WordPress plugin

Copy this directory into `wp-content/plugins/` and activate it alongside the WordPress AI Client.

### As a Composer package

```bash
composer require itzmekhokan/ai-provider-for-together
```

## Author

[Khokan Sardar](https://profiles.wordpress.org/khokansardar/)

## License

GPL-2.0-or-later
