Download the PHP package thinwrap/llm without Composer

On this page you can find all versions of the php package thinwrap/llm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package llm

thinwrap/llm

Unified, SDK-free PHP facade over LLM chat-completion & embeddings providers. One typed Chat facade; switch vendor by changing the provider id + model. Stateless, bring your own PSR-18 HTTP client, no vendor SDKs — the in-process, zero-egress complement to an LLM gateway.

Install

Requires PHP ≥8.2. A PSR-18 HTTP client + PSR-17 factories are auto-discovered via php-http/discovery — if you don't already have one installed:

End-to-end example

Switching providers

Change the LlmProviderId case, the config class, and the model; the input and output shape stay identical.

The 15 first-class OpenAI-compatible providers all take OpenAiCompatConfig: openai, azure-openai, openrouter, groq, together, fireworks, deepseek, xai, mistral, perplexity, deepinfra, cloudflare, vllm, ollama, lmstudio. anthropic, bedrock, and gemini are native adapters.

Per-provider docs (auth, config, quirks, rate-limit links, error mapping) live in src/Providers/ — one README per provider.

Streaming

stream() returns a \Generator<ChatStreamDelta>. It reads the provider's text/event-stream response off the PSR-7 body incrementally. Bedrock (whose stream uses AWS binary event-stream framing) falls back to a single Converse call replayed as deltas.

Embeddings

Bring your own PSR-18 client

Inject any PSR-18 client (and, optionally, PSR-17 factories) as constructor arguments — useful for tracing, retries, mocking, or proxying through symfony/http-client.

Contract: a non-2xx must be RETURNED, not thrown. PSR-18 requires this and compliant clients honour it, so each connector can map the status to a ProviderCode (429 → RateLimited, 401 → AuthFailed, …) and read the vendor's message. For an LLM caller that is the difference between backing off and treating a rate limit as an outage. A client that raises instead — Guzzle used outside its PSR-18 adapter, or a decorator calling raise-on-error — is handled defensively: the answered response is recovered from the exception's getResponse() so classification still runs.

The wrapper holds no state — no cache, no connection pool, no retry buffer. For an already-built connector (a custom provider, say), use Chat::fromConnector($connector).

_passthrough escape valve

When the normalized input doesn't expose a vendor-specific field, forward arbitrary keys via _passthrough on the input DTO. The connector deep-merges body, and merges headers / query; consumer values win on collision. Keys are forwarded verbatim.

Error handling

Every failure surfaces as ConnectorError with a typed ProviderCode (rate_limited, auth_failed, provider_unavailable, invalid_request, context_length_exceeded, content_filtered, unknown). There is no top-level retryAfterSeconds field — the raw Retry-After and its parsed seconds ride in $e->cause. The wrapper performs no automatic retry.

Security

Report vulnerabilities privately — please do not open a public issue. Preferred: a private security advisory on this repository. Alternatively, email [email protected]. Include the affected versions and a minimal reproduction if you have one.

A vulnerability in a provider's own API or service belongs to that vendor rather than to this wrapper — please report those upstream.

MIT © Dmitry Polyanovsky


All versions of llm with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0 || ^2.0
php-http/discovery Version ^1.20
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thinwrap/llm contains the following files

Loading the files please wait ...