{"record":{"id":"21869ff8b1be4300","repo":"appwrite/appwrite","slug":"invalid-model-model-supported-models-ollama","errorCode":null,"errorMessage":"Invalid model: {$model}. Supported models: ","messagePattern":"Invalid model: (.+?)\\. Supported models: ","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/agents/src/Adapters/Ollama.php","lineNumber":39,"sourceCode":"    public const MODELS = [self::MODEL_EMBEDDING_GEMMA];\n\n    /**\n     * Embedding dimensions of specific embedding model\n     */\n    protected const DIMENSIONS = [\n        self::MODEL_EMBEDDING_GEMMA => 768,\n    ];\n\n    /**\n     * Create a new Ollama adapter (no API key required for local call)\n     */\n    public function __construct(\n        string $model = self::MODEL_EMBEDDING_GEMMA,\n        int $timeout = 90000,\n        (ClientInterface&StreamingClientInterface)|null $client = null\n    ) {\n        if (! in_array($model, self::MODELS, true)) {\n            throw new \\InvalidArgumentException(\"Invalid model: {$model}. Supported models: \".implode(', ', self::MODELS));\n        }\n\n        $this->model = $model;\n        $this->client = $client;\n        $this->setTimeout($timeout);\n    }\n\n    /**\n     * Embedding generation (Ollama only supports embeddings, not chat)\n     *\n     * @return array{\n     *     embedding: array<int, float>,\n     *     tokensProcessed: int|null,\n     *     totalDuration: int|null ,\n     *     modelLoadingDuration: int|null\n     * }\n     *\n     * @throws \\Exception","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/appwrite/appwrite/blob/7eab5f1970bacb06f8cce069c27b7d14a4178153/packages/agents/src/Adapters/Ollama.php#L21-L57","documentation":"Thrown by the Ollama embedding adapter constructor when the given $model name is not in the adapter's allow-list (Ollama::MODELS, currently only MODEL_EMBEDDING_GEMMA). The adapter intentionally whitelists embedding models it knows how to work with instead of accepting arbitrary Ollama model tags. The message lists all supported models.","triggerScenarios":"new Ollama('llama3'), new Ollama('nomic-embed-text'), or any model string other than the exact supported embedding-gemma constant is passed to the constructor.","commonSituations":"Developers assume any locally pulled Ollama model works; typos in the model tag; upgrading Ollama and switching to a newer embedding model not yet allow-listed by the adapter.","solutions":["Use one of the supported constants, e.g. new Ollama(Ollama::MODEL_EMBEDDING_GEMMA)","Print Ollama::MODELS and pass exactly one of those strings","Request/patch support for the desired embedding model in the adapter's MODELS list"],"exampleFix":"// before\n$adapter = new Ollama('nomic-embed-text');\n// after\n$adapter = new Ollama(Ollama::MODEL_EMBEDDING_GEMMA);","handlingStrategy":"validation","validationCode":"if (! in_array($model, Ollama::MODELS, true)) { throw new \\InvalidArgumentException(\"Unsupported model: $model\"); }\n$adapter = new Ollama($model);","typeGuard":"function isValidOllamaModel(string $model): bool { return in_array($model, Ollama::MODELS, true); }","tryCatchPattern":null,"preventionTips":["Always construct with Ollama::MODEL_EMBEDDING_GEMMA or iterate Ollama::MODELS when offering a choice","Never hardcode Ollama model tags copied from Ollama docs; check the adapter allow-list"],"tags":["php","ollama","configuration","embeddings"],"backgroundTag":"invalid-enum-value","analyzedSha":"7eab5f1970bacb06f8cce069c27b7d14a4178153","analyzedAt":"2026-09-23T00:38:38.905Z","contentChangedAt":"2026-09-23T00:38:38.905Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}