> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/language-models/localai-openai-compatible.md).

# LocalAI

LocalAI के साथ एक self-hosted OpenAI-समर्थित API चलाएँ।

{% hint style="success" %}
सभी उदाहरण GPU सर्वरों पर चलाए जा सकते हैं जिन्हें द्वारा किराए पर लिया गया है [CLORE.AI मार्केटप्लेस](https://clore.ai/marketplace).
{% endhint %}

## सर्वर आवश्यकताएँ

| पैरामीटर      | न्यूनतम       | अनुशंसित |
| ------------- | ------------- | -------- |
| RAM           | 8GB           | 16GB+    |
| VRAM          | 6GB           | 8GB+     |
| नेटवर्क       | 200Mbps       | 500Mbps+ |
| स्टार्टअप समय | **5-10 मिनट** | -        |

{% hint style="warning" %}
**महत्वपूर्ण:** पहली बार स्टार्टअप पर LocalAI को पूरी तरह से आरंभ होने में 5-10 मिनट लगते हैं। इस दौरान HTTP 502 सामान्य है - सेवा मॉडल डाउनलोड और लोड कर रही है।
{% endhint %}

{% hint style="info" %}
LocalAI हल्का है। LLMs (7B+ मॉडल) चलाने के लिए 16GB+ RAM और 8GB+ VRAM वाले सर्वर चुनें।
{% endhint %}

## LocalAI क्या है?

LocalAI प्रदान करता है:

* ड्रॉप-इन OpenAI API प्रतिस्थापन
* कई मॉडल फ़ॉर्मैट के लिए समर्थन
* टेक्स्ट, इमेज, ऑडियो और एम्बेडिंग जनरेशन
* GPU आवश्यक नहीं (लेकिन GPU से तेज़ी आती है)

## समर्थित मॉडल

| प्रकार      | फ़ॉर्मैट    | उदाहरण              |
| ----------- | ----------- | ------------------- |
| LLM         | GGUF, GGML  | Llama, Mistral, Phi |
| एम्बेडिंग्स | GGUF        | all-MiniLM, BGE     |
| इमेजेस      | Diffusers   | SD 1.5, SDXL        |
| ऑडियो       | Whisper     | स्पीच-टू-टेक्स्ट    |
| TTS         | Piper, Bark | टेक्स्ट-टू-स्पीच    |

## त्वरित तैनाती

**Docker इमेज:**

```
localai/localai:master-aio-gpu-nvidia-cuda-12
```

**पोर्ट:**

```
22/tcp
8080/http
```

**किसी कमांड की आवश्यकता नहीं** - सर्वर अपने आप शुरू हो जाता है।

### जांचें कि यह काम कर रहा है

डिप्लॉयमेंट के बाद, अपना खोजें `http_pub` URL में **मेरे ऑर्डर** और परीक्षण करें:

```bash
# जाँचें कि सेवा तैयार है या नहीं
curl https://your-http-pub.clorecloud.net/readyz

# उपलब्ध मॉडल सूचीबद्ध करें
curl https://your-http-pub.clorecloud.net/v1/models

# संस्करण प्राप्त करें
curl https://your-http-pub.clorecloud.net/version
```

{% hint style="warning" %}
यदि आपको HTTP 502 मिलता है, तो 5-10 मिनट प्रतीक्षा करें - LocalAI को अन्य सेवाओं की तुलना में आरंभ होने में अधिक समय लग सकता है।
{% endhint %}

## प्री-बिल्ट मॉडल्स

LocalAI कई मॉडल के साथ बॉक्स से बाहर उपलब्ध आता है:

| मॉडल का नाम                | प्रकार      | विवरण                |
| -------------------------- | ----------- | -------------------- |
| `gpt-4`                    | चैट         | सामान्य-उद्देश्य LLM |
| `gpt-4o`                   | चैट         | सामान्य-उद्देश्य LLM |
| `gpt-4o-mini`              | चैट         | छोटा, तेज़ LLM       |
| `whisper-1`                | STT         | स्पीच-टू-टेक्स्ट     |
| `tts-1`                    | TTS         | टेक्स्ट-टू-स्पीच     |
| `text-embedding-ada-002`   | एम्बेडिंग्स | 384-आयामी वेक्टर     |
| `jina-reranker-v1-base-en` | रीरैंकिंग   | दस्तावेज़ रीरैंकिंग  |

{% hint style="info" %}
ये मॉडल अतिरिक्त कॉन्फ़िगरेशन के बिना स्टार्टअप के तुरंत बाद काम करते हैं।
{% endhint %}

## अपनी सेवा तक पहुँचना

CLORE.AI पर परिनियोजित होने पर, LocalAI को निम्न के माध्यम से एक्सेस करें `http_pub` URL:

```bash
# चैट पूर्णता
curl https://your-http-pub.clorecloud.net/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "gpt-4",
        "messages": [{"role": "user", "content": "Hello!"}]
    }'
```

{% hint style="info" %}
सभी `localhost:8080` नीचे दिए गए उदाहरण SSH के माध्यम से कनेक्ट होने पर काम करते हैं। बाहरी पहुंच के लिए, इसे अपने साथ बदलें `https://your-http-pub.clorecloud.net/` URL।
{% endhint %}

## Docker पर तैनाती (वैकल्पिक)

```bash
docker run -d \
    --gpus all \
    -p 8080:8080 \
    -v /workspace/models:/models \
    -e THREADS=4 \
    -e CONTEXT_SIZE=4096 \
    localai/localai:master-aio-gpu-nvidia-cuda-12
```

## मॉडल डाउनलोड करें

### मॉडल गैलरी से

LocalAI में एक बिल्ट-इन मॉडल गैलरी है:

```bash
# उपलब्ध मॉडल सूचीबद्ध करें
curl http://localhost:8080/models/available

# गैलरी से इंस्टॉल करें
curl http://localhost:8080/models/apply -d '{"id": "mistral-7b-instruct"}'
```

### Hugging Face से

```bash
mkdir -p /workspace/models

# Llama 3.1 8B GGUF
wget https://huggingface.co/bartowski/Meta-Llama-3.1-8B-Instruct-GGUF/resolve/main/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf \
    -O /workspace/models/llama-3.1-8b.gguf

# Mistral 7B GGUF
wget https://huggingface.co/bartowski/Mistral-7B-Instruct-v0.3-GGUF/resolve/main/Mistral-7B-Instruct-v0.3-Q4_K_M.gguf \
    -O /workspace/models/mistral-7b.gguf
```

## मॉडल कॉन्फ़िगरेशन

प्रत्येक मॉडल के लिए YAML कॉन्फ़िग बनाएं:

**models/llama-3.1-8b.yaml:**

```yaml
name: llama-3.1-8b
backend: llama-cpp
parameters:
  model: llama-3.1-8b.gguf
  context_size: 4096
  threads: 8
  gpu_layers: 35
template:
  chat: |
    {{.Input}}
    ### उत्तर:
  completion: |
    {{.Input}}
```

## API उपयोग

### चैट कम्पलीशन्स (OpenAI अनुकूल)

```python
import openai

# बाहरी पहुँच के लिए अपने http_pub URL का उपयोग करें:
client = openai.OpenAI(
    base_url="https://your-http-pub.clorecloud.net/v1",
    api_key="not-needed"
)

# या SSH टनल के माध्यम से:
# client = openai.OpenAI(base_url="http://localhost:8080/v1", api_key="not-needed")

response = client.chat.completions.create(
    model="mistral-7b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "क्वांटम कंप्यूटिंग को सरल शब्दों में समझाइए."}
    ],
    temperature=0.7,
    max_tokens=500
)

print(response.choices[0].message.content)
```

### स्ट्रीमिंग

```python
stream = client.chat.completions.create(
    model="mistral-7b",
    messages=[{"role": "user", "content": "AI के बारे में एक कविता लिखो"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
```

### एम्बेडिंग्स

```python
response = client.embeddings.create(
    model="all-minilm",
    input="The quick brown fox jumps over the lazy dog"
)

embedding = response.data[0].embedding
print(f"Embedding dimension: {len(embedding)}")
```

### इमेज जनरेशन

```python
response = client.images.generate(
    model="stablediffusion",
    prompt="a beautiful sunset over mountains",
    size="512x512",
    n=1
)

image_url = response.data[0].url
```

## cURL उदाहरण

### चैट

```bash
curl https://your-http-pub.clorecloud.net/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "mistral-7b",
        "messages": [{"role": "user", "content": "Hello!"}]
    }'
```

### एम्बेडिंग्स

```bash
curl https://your-http-pub.clorecloud.net/v1/embeddings \
    -H "Content-Type: application/json" \
    -d '{
        "model": "text-embedding-ada-002",
        "input": "Your text here"
    }'
```

प्रतिक्रिया:

```json
{
  "data": [{"embedding": [0.1, -0.2, ...], "index": 0}],
  "model": "text-embedding-ada-002",
  "usage": {"prompt_tokens": 4, "total_tokens": 4}
}
```

### टेक्स्ट-टू-स्पीच (TTS)

```bash
curl https://your-http-pub.clorecloud.net/v1/audio/speech \
    -H "Content-Type: application/json" \
    -d '{
        "model": "tts-1",
        "input": "Hello, welcome to LocalAI!",
        "voice": "alloy"
    }' \
    --output speech.wav
```

उपलब्ध आवाजें: `alloy`, `echo`, `fable`, `onyx`, `nova`, `shimmer`

### स्पीच-टू-टेक्स्ट (STT)

```bash
curl https://your-http-pub.clorecloud.net/v1/audio/transcriptions \
    -F "file=@audio.mp3" \
    -F "model=whisper-1"
```

प्रतिक्रिया:

```json
{"text": "Transcribed text here..."}
```

### रीरैंकिंग

क्वेरी के लिए प्रासंगिकता के अनुसार दस्तावेज़ों को रीरैंक करें:

```bash
curl https://your-http-pub.clorecloud.net/v1/rerank \
    -H "Content-Type: application/json" \
    -d '{
        "model": "jina-reranker-v1-base-en",
        "query": "What is machine learning?",
        "documents": [
            "Machine learning is a subset of AI",
            "The weather is nice today",
            "Deep learning uses neural networks"
        ],
        "top_n": 2
    }'
```

प्रतिक्रिया:

```json
{
  "results": [
    {"index": 0, "relevance_score": 0.95},
    {"index": 2, "relevance_score": 0.82}
  ]
}
```

## पूर्ण API संदर्भ

### मानक एंडपॉइंट्स (OpenAI अनुकूल)

| एंडपॉइंट                   | विधि | विवरण                     |
| -------------------------- | ---- | ------------------------- |
| `/v1/models`               | GET  | उपलब्ध मॉडल सूचीबद्ध करें |
| `/v1/chat/completions`     | POST | चैट कम्पलीशन              |
| `/v1/completions`          | POST | टेक्स्ट कम्पलीशन          |
| `/v1/embeddings`           | POST | एम्बेडिंग्स जनरेट करें    |
| `/v1/audio/speech`         | POST | टेक्स्ट-टू-स्पीच          |
| `/v1/audio/transcriptions` | POST | स्पीच-टू-टेक्स्ट          |
| `/v1/images/generations`   | POST | इमेज जनरेशन               |

### अतिरिक्त एंडपॉइंट्स

| एंडपॉइंट            | विधि | विवरण                        |
| ------------------- | ---- | ---------------------------- |
| `/readyz`           | GET  | तैयारी जाँच                  |
| `/healthz`          | GET  | हेल्थ जाँच                   |
| `/version`          | GET  | LocalAI संस्करण प्राप्त करें |
| `/v1/rerank`        | POST | दस्तावेज़ रीरैंकिंग          |
| `/models/available` | GET  | गैलरी मॉडल सूचीबद्ध करें     |
| `/models/apply`     | POST | गैलरी से मॉडल इंस्टॉल करें   |
| `/swagger/`         | GET  | Swagger UI दस्तावेज़ीकरण     |
| `/metrics`          | GET  | Prometheus मेट्रिक्स         |

#### वर्ज़न प्राप्त करें

```bash
curl https://your-http-pub.clorecloud.net/version
```

प्रतिक्रिया:

```json
{"version": "v2.26.0"}
```

#### Swagger दस्तावेज़ीकरण

इंटरऐक्टिव API डॉक्स के लिए ब्राउज़र में खोलें:

```
https://your-http-pub.clorecloud.net/swagger/
```

## GPU त्वरक

### CUDA बैकएंड

```yaml
# मॉडल कॉन्फ़िग में
parameters:
  gpu_layers: 35  # GPU पर लेयर्स की संख्या
  f16: true       # FP16 उपयोग करें
```

### पूर्ण GPU ऑफलोड

```yaml
parameters:
  gpu_layers: 99  # सभी लेयर्स GPU पर
  main_gpu: 0     # प्राथमिक GPU ID
```

## एकाधिक मॉडल

LocalAI एक ही समय में कई मॉडल सर्व कर सकता है:

```
models/
├── llama-3.1-8b.yaml
├── llama-3.1-8b.gguf
├── mistral-7b.yaml
├── mistral-7b.gguf
├── whisper.yaml
└── whisper-base.bin
```

API कॉल्स में मॉडल नाम द्वारा प्रत्येक तक पहुँचें।

## प्रदर्शन ट्यूनिंग

### गति के लिए

```yaml
parameters:
  threads: 8
  gpu_layers: 99
  batch_size: 512
  use_mmap: true
  use_mlock: true
```

### मेमोरी के लिए

```yaml
parameters:
  gpu_layers: 20  # आंशिक ऑफलोड
  context_size: 2048  # छोटा संदर्भ
  batch_size: 256
```

## बेंचमार्क्स

| मॉडल            | GPU      | टोकन/सेकंड |
| --------------- | -------- | ---------- |
| Llama 3.1 8B Q4 | RTX 3090 | \~100      |
| Mistral 7B Q4   | RTX 3090 | \~110      |
| Llama 3.1 8B Q4 | RTX 4090 | \~140      |
| Mixtral 8x7B Q4 | A100     | \~60       |

*बेंचमार्क जनवरी 2026 में अपडेट किए गए।*

## समस्याओं का निवारण

### http\_pub URL पर HTTP 502

LocalAI को अन्य सेवाओं की तुलना में शुरू होने में अधिक समय लगता है। प्रतीक्षा करें **5-10 मिनट** और पुनः प्रयास करें:

```bash
# तत्परता जाँच
curl https://your-http-pub.clorecloud.net/readyz

# हेल्थ जाँच
curl https://your-http-pub.clorecloud.net/healthz
```

### मॉडल लोड नहीं हो रहा

* YAML में फ़ाइल पथ जाँचें
* GGUF फ़ॉर्मैट संगतता सत्यापित करें
* उपलब्ध VRAM जाँचें

### धीमी प्रतिक्रियाएँ

* बढ़ाएँ `gpu_layers`
* सक्षम करें `use_mmap`
* घटाएँ `context_size`

### आउट ऑफ़ मेमोरी

* घटाएँ `gpu_layers`
* छोटी क्वांटाइज़ेशन का उपयोग करें (Q8 के बजाय Q4)
* बैच साइज घटाएँ

### इमेज जनरेशन समस्याएँ

{% hint style="warning" %}
कुछ GPU कॉन्फ़िगरेशन पर Stable Diffusion में CUDA संगतता समस्याएँ हो सकती हैं। यदि आप इमेज जनरेशन के साथ CUDA त्रुटियों का सामना करते हैं, तो समर्पित Stable Diffusion इमेज का उपयोग करने पर विचार करें।
{% endhint %}

## लागत अनुमान

सामान्य CLORE.AI मार्केटप्लेस दरें:

| GPU      | VRAM | प्राइस/दिन | उपयुक्त के लिए |
| -------- | ---- | ---------- | -------------- |
| RTX 3060 | 12GB | $0.15–0.30 | 7B मॉडल्स      |
| RTX 3090 | 24GB | $0.30–1.00 | 13B मॉडल्स     |
| RTX 4090 | 24GB | $0.50–2.00 | तेज़ इनफेरेंस  |
| A100     | 40GB | $1.50–3.00 | बड़े मॉडल्स    |

*मूल्य USD/दिन में हैं। दरें प्रदाता के अनुसार बदलती हैं — जांचें* [*CLORE.AI मार्केटप्लेस*](https://clore.ai/marketplace) *वर्तमान दरों के लिए।*

## अगले कदम

* [vLLM इनफेरेंस](/guides/guides_v2-hi/language-models/vllm.md) - उच्च थ्रूपुट
* [Ollama गाइड](/guides/guides_v2-hi/language-models/ollama.md) - सरल सेटअप
* [RAG with LangChain](/guides/guides_v2-hi/advanced/api-integration.md) - एप्लीकेशंस बनाएं


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/language-models/localai-openai-compatible.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
