Phi 4
Where it stands
Quality in independent tests against price, next to 135 other models. Up means more capable, left means cheaper.
About this model
Phi 4 is an AI model from Microsoft, made available through the API on January 10, 2025. It can read up to 16,384 tokens in one request, roughly 31 pages of text, and write up to 14,745 tokens in a single answer.
Through the API it costs $0.07 per million input tokens and $0.14 per million output tokens. Its pricing puts it among the more affordable models we track, which makes it a good fit for high-volume tasks.
Its weights are openly published (microsoft/phi-4), so it can also be downloaded and run on your own hardware.
Quality scores
Rankings →- GPQA DiamondVery hard multiple-choice questions in biology, physics and chemistry, written by PhD experts. Random guessing scores 25%.56.1%#92 of 116
- AIME mathCompetition-level math problems in the style of the American Invitational Mathematics Examination. Share solved.13.8%#95 of 112
Where to use it
Companies that serve this model through an API: 1. Prices per million tokens, cheapest first.
Availability and prices come from OpenRouter’s public API and are refreshed daily. Uptime is the share of successful requests over the last 24 hours. Some providers run a compressed version of open models (fp8, int4), which is cheaper but can be slightly less accurate.
Use it in your code
Call Phi 4 through OpenRouter’s OpenAI-compatible API: create a key on openrouter.ai, then run one of these examples.
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "microsoft/phi-4", "messages": [{"role": "user", "content": "Hello! What can you do?"}]}'import os
from openai import OpenAI
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=os.environ["OPENROUTER_API_KEY"])
reply = client.chat.completions.create(
model="microsoft/phi-4",
messages=[{"role": "user", "content": "Hello! What can you do?"}],
)
print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://openrouter.ai/api/v1", apiKey: process.env.OPENROUTER_API_KEY });
const reply = await client.chat.completions.create({
model: "microsoft/phi-4",
messages: [{ role: "user", content: "Hello! What can you do?" }],
});
console.log(reply.choices[0].message.content);The same code works with every model on this site: only the model ID changes. Many labs also offer their own API and SDK.
What it costs in practice
- 1,000 chat replies$0.077
- Summarise a 100-page document$0.0036
- An app with 10,000 requests a day for a month$37.80
Similar-priced alternatives
| Model | Inputi | Outputi | Contexti | |
|---|---|---|---|---|
Qwen3 Coder 30B A3B InstructAlibaba Qwen | $0.07 | $0.28 | 256K | Compare with ⇄ |
Hy-MT2-30B-A3BTencent | $0.074 | $0.30 | 8K | Compare with ⇄ |
Ternary Bonsai 2 27BPrism Ml | $0.075 | $0.50 | 256K | Compare with ⇄ |
Nex-N2.5-ProNex Agi | $0.075 | $0.25 | 256K | Compare with ⇄ |
Seed 1.6 FlashByteDance Seed | $0.075 | $0.30 | 256K | Compare with ⇄ |
gpt-oss-safeguard-20bOpenAI | $0.075 | $0.30 | 128K | Compare with ⇄ |
News about Microsoft
See all →Frequently asked questions
- How much does Phi 4 cost?
- Phi 4 costs $0.07 per million input tokens and $0.14 per million output tokens through the API. For example, 1,000 chat replies of about 500 tokens in and 300 out cost around $0.077.
- What is the context window of Phi 4?
- Phi 4 can read up to 16,384 tokens in one request, about 31 pages of text. It can write up to 14,745 tokens in a single answer.
- Is Phi 4 open source?
- Yes. Its weights are published (microsoft/phi-4), so you can download it and run it on your own hardware, or use it through one of 1 API providers.
- Who makes Phi 4?
- Phi 4 is made by Microsoft. It became available through the API on January 10, 2025.
- How good is Phi 4?
- Phi 4 has an overall index of 130.4 in Epoch AI’s independent tests, ranking #112 of 136 models we track.
- Can Phi 4 read images?
- No. Phi 4 only accepts text as input.
- What are the alternatives to Phi 4?
- Models with a similar price from other companies include Qwen3 Coder 30B A3B Instruct, Hy-MT2-30B-A3B and Ternary Bonsai 2 27B. You can compare them side by side on this page.