---
title: "Cum folosesc API-ul Ollama (REST și endpoint compatibil OpenAI)?"
url: "https://www.hostx.ro/kb/cum-folosesc-api-ul-ollama-rest-si-endpoint-compatibil-openai/"
updated: "2026-08-21"
category: Ollama
---

# Cum folosesc API-ul Ollama (REST și endpoint compatibil OpenAI)?

Pe lângă linia de comandă, Ollama expune un **API local** pe portul **11434**, cu care alte aplicații pot folosi modelele. Are atât un API propriu, cât și un endpoint **compatibil OpenAI**.

## Generarea de text (/api/generate)

```
curl http://127.0.0.1:11434/api/generate -d '{
  "model": "llama3.1",
  "prompt": "Explică pe scurt ce este un certificat SSL",
  "stream": false
}'
```

## Chat cu istoric (/api/chat)

```
curl http://127.0.0.1:11434/api/chat -d '{
  "model": "llama3.1",
  "messages": [
    {"role":"system","content":"Ești un asistent util."},
    {"role":"user","content":"Salut!"}
  ],
  "stream": false
}'
```

## Embeddings (/api/embeddings)

Pentru căutare semantică / RAG:

```
curl http://127.0.0.1:11434/api/embeddings -d '{
  "model": "nomic-embed-text",
  "prompt": "text de indexat"
}'
```

## Endpoint compatibil OpenAI

Ollama oferă și un endpoint compatibil OpenAI la `/v1`, astfel încât multe aplicații care „vorbesc” protocolul OpenAI îl pot folosi direct:

```
curl http://127.0.0.1:11434/v1/chat/completions -d '{
  "model": "llama3.1",
  "messages": [{"role":"user","content":"Salut!"}]
}'
```

## Streaming

Implicit, API-ul „transmite” răspunsul token cu token (streaming). Setează `"stream": false` dacă vrei răspunsul complet dintr-o dată.

**Sfat:** Endpointul compatibil OpenAI este cel mai simplu mod de a conecta Ollama la aplicații existente — de multe ori schimbi doar „base URL”-ul către `http://IP:11434/v1`.
<template id="hostx-kb-related-holder"><section class="hostx-kb-related" aria-label="Articole similare"><h2 class="hostx-kb-related__title">Articole similare</h2><div class="hostx-kb-related__grid"><a class="hostx-kb-related__card" href="https://www.hostx.ro/kb/cum-instalez-ollama-pe-un-vps-linux/"><span class="hostx-kb-related__ico"><svg aria-hidden="true" focusable="false"
  class="lucide lucide-file-text"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
  <path d="M14 2v5a1 1 0 0 0 1 1h5" />
  <path d="M10 9H8" />
  <path d="M16 13H8" />
  <path d="M16 17H8" />
</svg></span><span class="hostx-kb-related__name">Cum instalez Ollama pe un VPS (Linux)?</span></a><a class="hostx-kb-related__card" href="https://www.hostx.ro/kb/ce-este-ollama-si-la-ce-foloseste/"><span class="hostx-kb-related__ico"><svg aria-hidden="true" focusable="false"
  class="lucide lucide-file-text"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
  <path d="M14 2v5a1 1 0 0 0 1 1h5" />
  <path d="M10 9H8" />
  <path d="M16 13H8" />
  <path d="M16 17H8" />
</svg></span><span class="hostx-kb-related__name">Ce este Ollama și la ce folosește?</span></a><a class="hostx-kb-related__card" href="https://www.hostx.ro/kb/cum-conectez-ollama-la-open-webui-si-la-alte-aplicatii/"><span class="hostx-kb-related__ico"><svg aria-hidden="true" focusable="false"
  class="lucide lucide-file-text"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
  <path d="M14 2v5a1 1 0 0 0 1 1h5" />
  <path d="M10 9H8" />
  <path d="M16 13H8" />
  <path d="M16 17H8" />
</svg></span><span class="hostx-kb-related__name">Cum conectez Ollama la Open WebUI și la alte aplicații?</span></a><a class="hostx-kb-related__card" href="https://www.hostx.ro/kb/ollama-vs-lm-studio-llama-cpp-si-vllm-care-sunt-diferentele/"><span class="hostx-kb-related__ico"><svg aria-hidden="true" focusable="false"
  class="lucide lucide-file-text"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
  fill="none"
  stroke="currentColor"
  stroke-width="2"
  stroke-linecap="round"
  stroke-linejoin="round"
>
  <path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" />
  <path d="M14 2v5a1 1 0 0 0 1 1h5" />
  <path d="M10 9H8" />
  <path d="M16 13H8" />
  <path d="M16 17H8" />
</svg></span><span class="hostx-kb-related__name">Ollama vs LM Studio, llama.cpp și vLLM: care sunt diferențele?</span></a></div></section></template>