appwrite/appwrite · error · InvalidArgumentException

Invalid model: . Supported models

Error message

Invalid model: {$model}. Supported models: 

What it means

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.

Solutions

  1. Use one of the supported constants, e.g. new Ollama(Ollama::MODEL_EMBEDDING_GEMMA)
  2. Print Ollama::MODELS and pass exactly one of those strings
  3. Request/patch support for the desired embedding model in the adapter's MODELS list

Example fix

// before
$adapter = new Ollama('nomic-embed-text');
// after
$adapter = new Ollama(Ollama::MODEL_EMBEDDING_GEMMA);
Defensive patterns

Strategy: validation

Validate before calling

if (! in_array($model, Ollama::MODELS, true)) { throw new \InvalidArgumentException("Unsupported model: $model"); }
$adapter = new Ollama($model);

Type guard

function isValidOllamaModel(string $model): bool { return in_array($model, Ollama::MODELS, true); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of appwrite/appwrite@7eab5f1970 (2026-09-23). Data as JSON: /api/errors/21869ff8b1be4300. Report an issue: GitHub.

Appendix: source

Thrown at packages/agents/src/Adapters/Ollama.php:39

    public const MODELS = [self::MODEL_EMBEDDING_GEMMA];

    /**
     * Embedding dimensions of specific embedding model
     */
    protected const DIMENSIONS = [
        self::MODEL_EMBEDDING_GEMMA => 768,
    ];

    /**
     * Create a new Ollama adapter (no API key required for local call)
     */
    public function __construct(
        string $model = self::MODEL_EMBEDDING_GEMMA,
        int $timeout = 90000,
        (ClientInterface&StreamingClientInterface)|null $client = null
    ) {
        if (! in_array($model, self::MODELS, true)) {
            throw new \InvalidArgumentException("Invalid model: {$model}. Supported models: ".implode(', ', self::MODELS));
        }

        $this->model = $model;
        $this->client = $client;
        $this->setTimeout($timeout);
    }

    /**
     * Embedding generation (Ollama only supports embeddings, not chat)
     *
     * @return array{
     *     embedding: array<int, float>,
     *     tokensProcessed: int|null,
     *     totalDuration: int|null ,
     *     modelLoadingDuration: int|null
     * }
     *
     * @throws \Exception

View on GitHub (pinned to 7eab5f1970)