Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ai Ollama Platform Laravel Package

symfony/ai-ollama-platform

Ollama platform bridge for Symfony AI, connecting your applications to locally hosted Ollama models for chat, embeddings, and NDJSON streaming through the Symfony AI component ecosystem.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Local AI Infrastructure: Enables self-hosted LLM workflows in Laravel/Symfony apps, reducing reliance on cloud providers (e.g., OpenAI) for cost, latency, or compliance. Aligns with trends toward on-premise AI and edge computing.
  • AI-First Roadmap: Accelerates delivery of AI-powered features (e.g., chatbots, embeddings, structured data extraction) without reinventing low-level API wrappers. Supports Symfony AI ecosystem for future scalability.
  • Build vs. Buy: Buy—avoids reinventing Ollama API clients, authentication, streaming, and model routing. Leverages Symfony’s maintained ecosystem (MIT license) for long-term reliability.
  • Use Cases:
    • Real-Time Chat/Assistants: Streaming NDJSON responses for conversational UIs (e.g., customer support, internal tools).
    • Embeddings & Search: Local vector databases (e.g., Qdrant, Weaviate) paired with Ollama models for hybrid search (e.g., document retrieval).
    • Structured Outputs: Parse LLM responses into JSON/arrays for workflow automation (e.g., data extraction, form filling).
    • Multimodal AI: Audio capabilities (e.g., gemma:2b) for voice-to-text, transcription, or multimodal prompts.
    • Offline/Edge AI: Deploy models locally for low-latency or air-gapped systems (e.g., healthcare, defense, IoT).
    • Cost Optimization: Replace cloud API calls (e.g., OpenAI) with local inference for high-volume internal tools (e.g., batch processing, data labeling).
    • Usage & Cost Attribution (new in v0.14.0): TokenUsage now carries the model alongside token counts, enabling per-model cost calculation and chargeback across teams, features, or tenants—useful for metering internal AI usage, forecasting hardware spend, and validating the savings case for self-hosting.
  • Tech Stack Alignment:
    • Symfony: Native integration with symfony/ai; minimal glue code for chat/embeddings.
    • Laravel: Requires adapters (e.g., wrapping Symfony’s HttpClient) but enables reuse of Ollama’s capabilities.
  • Compliance & Security:
    • Data Sovereignty: Process sensitive data locally (e.g., GDPR, HIPAA) without cloud exposure.
    • Vendor Lock-In Avoidance: Use open-source models (e.g., Llama, Mistral) via Ollama, not proprietary APIs.

When to Consider This Package

Adopt if:

  • Your Laravel/Symfony app needs Ollama integration with minimal boilerplate (chat, embeddings, streaming).
  • You prioritize local AI for cost, latency, or compliance (e.g., GDPR, edge devices).
  • Your use case requires structured outputs (JSON/arrays) or audio capabilities (e.g., gemma:2b).
  • You need token/cost accounting per model (v0.14.0+) to meter usage, allocate AI spend, or report on inference economics.
  • You’re using Symfony AI or want to align with Symfony’s ecosystem (long-term maintainability).
  • Your team can manage Ollama infrastructure (Docker, model updates, scaling).
  • You need real-time streaming (NDJSON/SSE) for chat interfaces or incremental processing.

Look elsewhere if:

  • You require cloud-scale AI (e.g., OpenAI, Anthropic) or managed services (e.g., AWS Bedrock).
  • Your use case demands custom model training/fine-tuning (Ollama supports inference only; use Hugging Face or vLLM for training).
  • You’re not using Symfony/Laravel (though PHP-agnostic, Symfony integration adds value).
  • Your team lacks PHP 8.1+ or Symfony/Laravel expertise (though the API is straightforward).
  • You need GPU acceleration beyond Ollama’s native support (e.g., vLLM, TensorRT-LLM).
  • Ollama infrastructure is prohibitive (e.g., no Docker, limited hardware for large models).

How to Pitch It (Stakeholders)

For Executives: *"This package enables local AI deployment using Ollama, cutting cloud API costs and improving latency for internal tools. Key benefits:

  • Cost Savings: Replace OpenAI calls (e.g., $0.002/1K tokens) with free local inference for high-volume use cases (e.g., batch processing, data labeling). As of v0.14.0, token usage reports include the model, so you can calculate and attribute cost per model—proving the savings rather than estimating them.
  • Compliance: Process sensitive data on-premise (e.g., healthcare, finance) without cloud exposure.
  • Speed: Sub-100ms responses for edge devices or air-gapped systems (e.g., defense, IoT).
  • Future-Proof: Aligns with Symfony’s AI ecosystem, avoiding vendor lock-in. Example: Launch a local chatbot for customer support or a document search assistant using Ollama’s llama3 model—in weeks, not months—with real-time streaming responses. Risk: Requires Ollama server setup (Docker/managed service), but payback is immediate for cost-sensitive or latency-critical use cases."*

For Engineering: *"This is a production-ready Ollama client for Symfony/Laravel, handling:

  • Authentication: Seamless integration with Symfony’s HttpClient (or Laravel’s Http facade with adapters).
  • Streaming: NDJSON/SSE support for real-time chat UIs (no manual chunk parsing).
  • Model Routing: Dynamic model selection (e.g., route gemma:2b for audio tasks via Provider abstraction).
  • Structured Outputs: Parse LLM responses into JSON/arrays for programmatic use (e.g., workflows).
  • Usage Telemetry (v0.14.0): TokenUsage exposes the model used, so prompt/completion token counts can be priced per model—wire this into your logging/metrics stack without custom parsing.
  • Audio/Multimodal: Use models like gemma:2b for voice-to-text or audio analysis. Why not build?
  • Maintenance: Symfony’s team handles updates (e.g., streaming bug fixes in v0.7.0; token-cost metadata in v0.14.0).
  • Testing: Battle-tested with Symfony AI; Laravel integration is low-risk with adapters.
  • Speed: Focus on your app logic—no HTTP clients, NDJSON parsing, or auth to write. Use it for:
  • Chatbots, embeddings, or any use case where you’d call Ollama’s API directly.
  • Laravel Workaround: Wrap Symfony’s OllamaClient in a service using Laravel’s Http facade (see example below).
// Laravel Service Example
use Symfony\Component\AI\Ollama\OllamaClient;
use Illuminate\Support\Facades\Http;

class OllamaService {
    public function __construct() {
        $this->client = new OllamaClient(
            Http::macro('createClient', fn() => Http::client())
        );
    }

    public function chat(string $model, string $prompt) {
        return $this->client->chat($model, $prompt);
    }
}

Caveats:

  • Requires Ollama server (Docker setup recommended).
  • Symfony abstractions (e.g., Provider) need Laravel adapters for full feature parity.
  • Test streaming with Laravel’s event loop (e.g., Pusher, Swoole)."*

For Data/ML Teams: *"This package enables local LLM inference for:

  • Embeddings: Generate vectors with Ollama models (e.g., nomic-embed-text) for vector search (e.g., Qdrant, Weaviate).
  • Hybrid Search: Combine Ollama embeddings with traditional search (e.g., Elasticsearch) for semantic retrieval.
  • Structured Data Extraction: Use structured_output (v0.7.0) to parse LLM responses into JSON/arrays for ML pipelines.
  • Cost & Usage Tracking: TokenUsage now includes the model (v0.14.0), so per-model token accounting flows straight into experiment tracking and cost dashboards. Example: Deploy a local RAG system (Retrieval-Augmented Generation) with Ollama + a vector DB, avoiding cloud API costs. Limitations:
  • No fine-tuning (use Hugging Face for training).
  • Model performance depends on Ollama’s hardware (e.g., GPU for large models like llama3)."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk