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

# DeepInfra Native API

> Advanced API with access to all model types including image generation, speech, and zero-shot image classification.

The DeepInfra Native API gives you access to every model we provide, including model types not covered by the OpenAI-compatible API: image generation, speech recognition, and zero-shot image classification.

For LLMs and embeddings, the [OpenAI-compatible API](/chat/overview) is simpler and recommended. Use the native API when you need model types beyond LLMs/embeddings, or when you need features like [webhooks](/account/webhooks) or [log probabilities](/chat/log-probs).

The base endpoint is:

```
https://api.deepinfra.com/v1/inference/{model_name}
```

## JavaScript client

```bash theme={null}
npm install deepinfra
```

## Text Generation (LLMs)

This endpoint takes a **raw prompt** — it does not apply the model's chat template. Pass pre-formatted text, or use the [OpenAI-compatible chat API](/chat/overview), which applies the template for you. Each model's page lists its chat template.

```javascript theme={null}
import { TextGeneration } from "deepinfra";

const client = new TextGeneration(
  "https://api.deepinfra.com/v1/inference/deepseek-ai/DeepSeek-V4-Flash-0731",
  process.env.DEEPINFRA_API_KEY
);

const res = await client.generate({
  input: "The capital of France is",
  max_new_tokens: 20
});

console.log(res.results[0].generated_text);
console.log(res.num_input_tokens, res.num_tokens);
```

```bash theme={null}
curl "https://api.deepinfra.com/v1/inference/deepseek-ai/DeepSeek-V4-Flash-0731" \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer $DEEPINFRA_API_KEY" \
   -d '{
     "input": "The capital of France is",
     "max_new_tokens": 20,
     "stream": false
   }'
```

## Embeddings

```javascript theme={null}
import { Embeddings } from "deepinfra";

const client = new Embeddings("Qwen/Qwen3-Embedding-8B", process.env.DEEPINFRA_API_KEY);
const output = await client.generate({
  inputs: [
    "What is the capital of France?",
    "What is the capital of Germany?",
  ],
});
console.log(output.embeddings[0]);
```

```bash theme={null}
curl -X POST \
    -H "Authorization: Bearer $DEEPINFRA_API_KEY" \
    -F 'inputs=["I like chocolate"]' \
    'https://api.deepinfra.com/v1/inference/Qwen/Qwen3-Embedding-8B'
```

## Image Generation

```javascript theme={null}
import { TextToImage } from "deepinfra";
import { createWriteStream } from "fs";
import { Readable } from "stream";

const model = new TextToImage("stabilityai/sdxl-turbo", process.env.DEEPINFRA_API_KEY);
const response = await model.generate({
  prompt: "a burger with a funny hat on the beach",
});

const result = await fetch(response.images[0]);
if (result.ok && result.body) {
  Readable.fromWeb(result.body).pipe(createWriteStream("image.jpg"));
}
```

```bash theme={null}
curl "https://api.deepinfra.com/v1/inference/stabilityai/sdxl-turbo" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DEEPINFRA_API_KEY" \
  -d '{"prompt": "a burger with a funny hat on the beach"}'
```

## Speech Recognition

```bash theme={null}
curl -X POST \
    -H "Authorization: Bearer $DEEPINFRA_API_KEY" \
    -F audio=@audio.mp3 \
    'https://api.deepinfra.com/v1/inference/openai/whisper-large-v3'
```

## Zero-Shot Image Classification

```bash theme={null}
curl -X POST \
    -H "Authorization: Bearer $DEEPINFRA_API_KEY" \
    -F image=@image.jpg \
    -F 'candidate_labels=["dog", "cat", "car", "horse", "person"]' \
    'https://api.deepinfra.com/v1/inference/openai/clip-vit-base-patch32'
```

## HTTP / other languages

The native API is plain HTTP — you can use it from any language (Go, C#, Java, PHP, Ruby, C++, etc.) without any SDK dependency.


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