Download the PHP package cable8mm/nano-ai without Composer
On this page you can find all versions of the php package cable8mm/nano-ai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cable8mm/nano-ai
More information about cable8mm/nano-ai
Files in cable8mm/nano-ai
Package nano-ai
Short Description A lightweight, zero-configuration PHP SDK for straightforward text generation and multimodal AI interactions.
License MIT
Homepage https://github.com/cable8mm/nano-ai
Informations about the package nano-ai
NanoAI
Ultra-lightweight, zero-config PHP AI SDK. No agents/RAG — just generate() for text + image (multimodal) calls.
Use it for testing, lightweight pipelines, and idea validation.
Supported Providers
| Provider | Description |
|---|---|
openai |
Direct connection to OpenAI Chat Completions |
openrouter |
Call most models (OpenAI/Gemini/DeepSeek/Qwen, etc.) via a single API by just changing the model name. Free models use :free suffix |
Installation
Usage
Configuration Options
The Client constructor accepts an optional $options array to customize behavior:
Available Options
| Option | Type | Default | Description |
|---|---|---|---|
timeout |
int |
120 |
Maximum time to wait for API response (seconds) |
connectTimeout |
int |
30 |
Maximum time to establish connection (seconds) |
baseUrl |
string |
Provider default | Override the API base URL |
referer |
string |
None | Custom Referer header sent with requests |
title |
string |
None | Custom X-Title header sent with requests |
Note: Options like baseUrl, referer, and title are particularly useful when using OpenRouter or custom OpenAI-compatible APIs.
To test with free/low-cost models:
Exceptions
AuthenticationException— Missing/invalid API Key (401/403)RateLimitException— Request rate limit exceeded (429), common with free modelsApiException— Other API errors, providesgetStatusCode()/getResponseBody()NetworkException— cURL-level failures such as timeouts
All extend NanoAIException, so you can catch them all at once.
Using Guzzle as the HTTP Client (Optional)
By default, nano-ai uses a minimal cURL-based HTTP client with zero external dependencies.
If you prefer Guzzle (or need its advanced features like middleware, retries, proxies, etc.),
install it and inject the provided GuzzleHttpClient:
The GuzzleHttpClient implements the same HttpClientInterface as the default cURL client,
so it is a drop-in replacement. All nano-ai features (timeouts, error handling, etc.) work identically.
Adding a New Provider
Create a class implementing NanoAI\Provider\ProviderInterface (if it's an OpenAI-compatible API, you can extend AbstractOpenAICompatibleProvider), then add one line to ProviderFactory::make().
No need to modify Client or HttpClient.
Development
End-to-End Testing (Real API)
The default test suite uses mock servers and fake HTTP clients — no external network access required.
To verify against the real OpenAI/OpenRouter APIs:
These tests are opt-in and skipped by default. They make real API calls
and may incur costs. The tests/config.json file is gitignored and will
never be committed.
License
MIT
All versions of nano-ai with dependencies
ext-curl Version *
ext-json Version *