# ovok.ai

Canonical page: https://docs.ovok.com/web-sdk/core/namespaces/ai

AI features of the Ovok API, called by a signed-in app. Routes live under `ai`.

## Translate text [#translate-text]

```ts
const result = await ovok.ai.translate({
  sourceLanguage: 'en',
  targetLanguage: 'de',
  text: ['Take one tablet daily.'],
});
```

- `text` is an array, and the response has the same shape with the translated strings.

## Run a chat session [#run-a-chat-session]

Create a session with an assistant prompt, then send messages to it. `send` returns the reply.

```ts
await ovok.ai.chat.sessions.create({
  assistant: { system: 'You answer questions about sleep.' },
  participant: 'Patient/123',
  messages: [],
});

// sessionId identifies a session you created or listed.
const reply = await ovok.ai.chat.messages.send(sessionId, {
  sender: 'Patient/123',
  content: 'Why do I wake up at night?',
});

const history = await ovok.ai.chat.messages.list(sessionId, { _sort: 'sent', _count: 20 });
```

- `ovok.ai.chat.sessions` has `create`, `list` and `retrieve`. `retrieve` accepts `messageCount` to include the latest messages.
- `ovok.ai.chat.messages` has `list` and `send`.
- `list` calls return the server's response envelope, not a `PagePromise`.

## Search FHIR data in natural language [#search-fhir-data-in-natural-language]

```ts
const answer = await ovok.ai.fhirSearch({ text: 'Latest blood pressure of Jane Doe' });

console.log(answer.markdown);
```

- An LLM plans and runs the FHIR queries, so the answer can be wrong or invented. The response includes the `plan` that was run so you can check it.
- `fhirVersion: 'R4' | 'R5'` pins the version; omitted, the server default applies.
- For queries you control, use [ovok.fhir](/web-sdk/core/namespaces/fhir).

## Reference [#reference]

- [ai API reference](/web-sdk/core/reference/core/ai): every method and type.
- [ovok.fhir](/web-sdk/core/namespaces/fhir)
- [Errors and retries](/web-sdk/core/errors-and-retries)
