> ## Documentation Index
> Fetch the complete documentation index at: https://docs.marina.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# AI

> Generate text with marina.ai using managed model classes or specific models from Marina's library.

Declare the service in `marina.json`, then call `marina.ai.generate`:

```json marina.json theme={null}
{
  "schema": 1,
  "entrypoint": "src/app.ts",
  "runtime": { "ai": "v1" }
}
```

```ts theme={null}
const result = await marina.ai.generate({
  model: "smart",
  messages: [
    { role: "system", content: "Return a concise factual summary." },
    { role: "user", content: report },
  ],
  maxOutputTokens: 800,
});
return new Response(result.text);
```

Apps never handle provider credentials or SDKs; Marina routes the call and
returns `{ text }`.

## Choosing a model

`model` accepts a stable class or a specific model id:

* **`fast`**: quick, inexpensive responses.
* **`smart`**: the stronger default for most work.
* **A model id** from Marina's library, in `vendor/model` form, for example
  `anthropic/claude-sonnet-5`.

List what your deployment offers, and which account pays, with:

```bash theme={null}
marina ai models
```

Unknown ids are rejected with the offered list in the error message.

## Who pays

By default, generations bill the organization's Marina-managed key. To bill
your own account instead, add an **OpenRouter** connection under
**Settings → Connections** with your `sk-or-` API key. While it is active,
your workspace's generations run on your OpenRouter account and its model
access.

## Limits

* Up to 64 messages per request; 32 KiB per message; 128 KiB total input.
* `maxOutputTokens` up to 4,096 (default 1,024 for `fast`, 2,048 otherwise).
* Roles are `system`, `user`, and `assistant`; content is text.
* Generation is non-streaming.

Prompts and generated text are never logged or stored by Marina.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.