# Microsoft: Phi 4

Phi 4 is Microsoft's small language model, built to answer prompts in a chat format and aimed mainly at math, coding and general reasoning. It is trained chiefly on English text, so it is not intended for multilingual use.

- **Model id:** `opencheap/phi-4`
- **Price per 1M tokens:** $0.07 input / $0.14 output
- **Context:** 16K tokens, 16K max output

## Providers

4 providers. Prices are per 1M tokens. As of 2026-12-04 12:05 UTC.

| Provider | Input price | Cache price | Output price | Latency | Speed | Uptime | Context | Max output |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| DeepInfra · Route 1 · bf16 | $0.059 | $0.059* | $0.12 | — | — | — | 16K | 14K |
| DeepInfra · Route 2 · bf16 | $0.073 | $0.073* | $0.15 | 0.26 s | 93 tok/s | 100 % | 16K | 14K |
| Hugging Face · deepinfra · bf16 | $0.07 | $0.07* | $0.14 | — | — | — | 16K | — |
| AiHubMix · quantization unknown | $0.12 | $0.12* | $0.48 | — | — | — | 16K | 16K |

\* No cache discount from this provider: cached tokens cost the input price.

1 more provider through partner hosts · from $0.073 in · $0.15 out

A request picks by price (`:floor`) or by speed (`provider.sort`, `:nitro`), or sets a floor on tokens per second. [How routing works](https://docs.opencheap.si/speed)

### Supported parameters

The parameters each provider supports on this model, from its published list and our own tests of whether answers show the parameter taking effect. A test is a snapshot, not a guarantee; `provider.require_parameters` sends a request only to providers that support every parameter it sets. [Required parameters](https://docs.opencheap.si/speed#require-parameters)

- **DeepInfra:** `temperature`, `top_p`, `top_k`, `min_p`, `seed`, `logit_bias`, `repetition_penalty`, `frequency_penalty`, `presence_penalty`, `stop`, `response_format`, `structured_outputs` (tools not confirmed)
- **Hugging Face · deepinfra:** `temperature`, `top_p`, `top_k`, `seed`, `logit_bias`, `frequency_penalty`, `presence_penalty`, `stop`, `response_format`, `structured_outputs` (tools not confirmed)
- **AiHubMix:** `temperature`, `top_p`, `top_k`, `seed`, `logit_bias`, `presence_penalty`, `stop`, `response_format`, `structured_outputs`, `tools`, `tool_choice`

## Price history

Each provider's price over the last 24 hours, 7 days and 30 days is charted on [the page](https://opencheap.si/models/phi-4#price-history).

## API

Point the OpenAI SDK at OpenCheap and pass the model id `opencheap/phi-4`; the rest of your code stays the same.

```bash
curl https://api.opencheap.si/v1/chat/completions \
  -H "Authorization: Bearer $OPENCHEAP_API_KEY" -H "Content-Type: application/json" \
  -d '{ "model": "opencheap/phi-4", "messages": [{ "role": "user", "content": "Hi" }] }'
```

```python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.opencheap.si/v1", api_key=os.environ["OPENCHEAP_API_KEY"])
r = client.chat.completions.create(model="opencheap/phi-4",
    messages=[{"role": "user", "content": "Hi"}])
print(r.choices[0].message.content)
```

```javascript
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.opencheap.si/v1", apiKey: process.env.OPENCHEAP_API_KEY });
const r = await client.chat.completions.create({ model: "opencheap/phi-4",
  messages: [{ role: "user", content: "Hi" }] });
console.log(r.choices[0].message.content);
```

## About Phi 4

Phi 4 costs from $0.07 per 1M input tokens and $0.14 per 1M output tokens on OpenCheap. Its list price is $0.07 per 1M input tokens and $0.14 per 1M output tokens, the same as here. At that price, a request with 10,000 input tokens and 1,000 output tokens costs about $0.00084, and 1,000 such requests about $0.84. Prices as of 2026-12-04 12:01 UTC.

4 providers serve Phi 4 on OpenCheap. Each request goes to the cheapest healthy provider of the model, and every answer reports what it cost in `usage.cost`. Its context window is 16K tokens (16,384), room for roughly 12,000 words of English in one request.

Phi 4 is one of [9 Microsoft models](https://opencheap.si/models/lab/microsoft) on OpenCheap. Every model on OpenCheap is called with one key at the same OpenAI-compatible endpoint, `https://api.opencheap.si/v1`.

## Pricing questions

### How much does the Phi 4 API cost per 1M tokens?

Phi 4 costs from $0.07 per 1M input tokens and $0.14 per 1M output tokens on OpenCheap. Prices as of 2026-12-04 12:01 UTC.

### What does one Phi 4 request cost?

A request with 10,000 input tokens and 1,000 output tokens costs about $0.00084, and 1,000 such requests about $0.84. Every answer reports its own cost in usage.cost.

### Is Phi 4 cheaper on OpenCheap than its list price?

Its list price is $0.07 per 1M input tokens and $0.14 per 1M output tokens, the same as here.

### Which providers serve Phi 4?

4 providers serve Phi 4 on OpenCheap. Each request goes to the cheapest healthy provider of the model; the table on this page lists every provider with its price, speed and uptime.

### What is the context window of Phi 4?

Its context window is 16K tokens (16,384), room for roughly 12,000 words of English in one request.

### How do I call the Phi 4 API?

Point the OpenAI SDK at https://api.opencheap.si/v1 and pass the model id opencheap/phi-4. One OpenCheap key works for every model; the rest of your code stays the same.

## More from Microsoft

- [Mai Thinking 1](https://opencheap.si/models/mai-thinking-1) (`mai-thinking-1`): $2.00 / $8.00 per 1M · 256K context
- [Phi 3.5 Vision Instruct](https://opencheap.si/models/phi-3.5-vision) (`phi-3.5-vision`): $0.40 / $1.60 per 1M
- [Phi 4 Mini Instruct](https://opencheap.si/models/phi-4-mini) (`phi-4-mini`): $0.12 / $0.48 per 1M · 128K context
- [Phi 4 Mini (reasoning)](https://opencheap.si/models/phi-4-mini-reasoning) (`phi-4-mini-reasoning`): $0.12 / $0.12 per 1M · 128K context
- [Phi 4 Multimodal Instruct](https://opencheap.si/models/phi-4-multimodal) (`phi-4-multimodal`): $0.07 / $0.11 per 1M · 128K context
- [WizardLM-2 8x22B](https://opencheap.si/models/wizardlm-2-8x22b) (`wizardlm-2-8x22b`): $0.49 / $0.49 per 1M · 65K context
- [Microsoft-Decision-1](https://opencheap.si/models/microsoft-decision-1) (`microsoft-decision-1`): $0.048 per 1M input · 32K context
- [Microsoft-Decision-1.1](https://opencheap.si/models/microsoft-decision-1.1) (`microsoft-decision-1.1`): $0.048 per 1M input · 32K context

[All 9 Microsoft models](https://opencheap.si/models/lab/microsoft)

## Similar models

- [GLM 4.7](https://opencheap.si/models/glm-4.7): Zhipu · 202K context · $0.032 / $0.14 per 1M, 8 % cheaper · [Compare with Phi 4](https://opencheap.si/compare/phi-4-vs-glm-4.7)
- [GLM 4.6](https://opencheap.si/models/glm-4.6): Zhipu · 202K context · $0.044 / $0.18 per 1M · [Compare with Phi 4](https://opencheap.si/compare/phi-4-vs-glm-4.6)
- [Reka Edge](https://opencheap.si/models/reka-edge): Reka · 16K context · $0.10 / $0.10 per 1M, 14 % cheaper · [Compare with Phi 4](https://opencheap.si/compare/phi-4-vs-reka-edge)
- [Xiaomi Mimo V2.6 Pro](https://opencheap.si/models/mimo-v2.6-pro): Xiaomi · 1M context · $0.054 / $0.11 per 1M, 23 % cheaper · [Compare with Phi 4](https://opencheap.si/compare/phi-4-vs-mimo-v2.6-pro)
- [Hy-MT2-1.8B](https://opencheap.si/models/hy-mt2-1.8b): Tencent · 8.1K context · $0.046 / $0.19 per 1M · [Compare with Phi 4](https://opencheap.si/compare/phi-4-vs-hy-mt2-1.8b)
- [Schematron V2 Turbo](https://opencheap.si/models/schematron-v2-turbo): Inference.net · 128K context · $0.03 / $0.15 per 1M · [Compare with Phi 4](https://opencheap.si/compare/phi-4-vs-schematron-v2-turbo)

[Compare Phi 4 with any model](https://opencheap.si/compare)

---

Source: https://opencheap.si/models/phi-4 · All models: https://opencheap.si/models · Prices as JSON: https://api.opencheap.si/v1/prices · Index for agents: https://opencheap.si/llms.txt
