Skip to content
Phi 4 logo

Phi 4

Verified

Microsoft's Phi-4 offers efficient open-weight text reasoning.

MicrosoftLanguage ModelsOpenII 10.4
Model page
Updated 2026-06-15

About Phi 4

Phi-4 belongs to Microsoft's Phi family of models that prioritize high-quality synthetic and curated data during training. This approach enables solid performance within a compact architecture while maintaining a 16384-token context window for extended inputs. The open-weight release facilitates inspection, modification, and deployment by the wider community.

Strengths include strong general language understanding and generation across reasoning, summarization, and dialogue tasks. Its design favors efficiency, allowing effective operation without requiring massive computational resources compared to larger proprietary systems.

Typical usage covers chat interfaces, document analysis pipelines, and fine-tuned domain applications. Developers commonly integrate it into local or edge environments where text-only processing and open licensing are priorities.

Capabilities

Mathematical reasoning
Code generation
Logical problem solving
Instruction following
Long-context text comprehension
General knowledge QA

Benchmarks & performance

Independent evaluation scores and measured speed.

10.4
Intelligence Index
11.2
Coding Index
0
Agentic Index
33
Tokens / sec
2.11s
Time to first token

Source: Artificial Analysis

How Phi 4 compares

Phi 4 (striped bar) vs other language models on intelligence, speed and price.

Intelligence

Artificial Analysis Intelligence Index · Higher is better · Phi 4 ranks #61 of 67

13
Qwen3 14B
13
Mistral Small 3
13
Qwen3 30B A3B
12
Granite 4.1 8B
11
Qwen3 8B
11
LFM2-24B-A2B
10
Phi 4
10
Mistral Large
10
Mixtral 8x22B Instruct
10
Reka Flash 3
8
Phi 4 Mini Instruct
8
Granite 4.0 Micro
7
Command R+

Speed

Output tokens per second · Higher is better · Phi 4 ranks #43 of 45

60
Qwen3 235B A22B Instruct 2507
60
Qwen3 235B A22B
59
GLM 4.6
52
Qwen3 Max Thinking
52
MiMo-V2.5-Pro
49
R1 Distill Llama 70B
49
GLM 4.5
45
Qwen3.6 Max Preview
45
MiniMax M2.7
39
Qwen3 8B
33
Phi 4
25
Kimi K2 0905
21
Phi 4 Mini Instruct

Price

USD per 1M output tokens · Lower is better · Phi 4 ranks #16 of 141

$0.11
Granite 4.0 Micro
$0.12
LFM2-24B-A2B
$0.12
Gemma 3n 4B
$0.14
gpt-oss-20b
$0.14
Nova Micro 1.0
$0.14
Llama 3 8B Instruct
$0.14
Phi 4
$0.15
Trinity Mini
$0.15
Command R7B
$0.15
Rnj 1 Instruct
$0.18
DeepSeek V4 Flash
$0.18
gpt-oss-120b
$0.19
Qwen3 30B A3B Instruct 2507

Sources: Artificial Analysis (intelligence, speed) · OpenRouter (price).

Best for

Mathematical Problem Solving

Phi 4 excels in educational or research scenarios requiring step-by-step solutions to advanced math problems using its mathematical reasoning strengths.

Code Generation Tasks

Software developers can rely on Phi 4 to generate, debug, and optimize code snippets efficiently through its dedicated code generation capabilities.

Long Document Analysis

Users handling lengthy reports or texts benefit from Phi 4's ability to comprehend and answer questions across its full 16384-token context window.

Strengths & limitations

Strengths

  • +Strong reasoning for model size
  • +Efficient inference
  • +High-quality STEM performance
  • +Clean, focused outputs

Limitations

  • Text-only modality
  • 16k token context limit
  • Less broad knowledge than larger models

Cost calculator

Estimate what Phi 4 would cost for your usage.

$0.00014
per request
$1.4
estimated / month

Based on Phi 4's $0.07/1M input · $0.14/1M output. Estimate only — actual cost varies by provider and caching.

Quick start

OpenRouter's API is OpenAI-compatible — most SDKs work by just swapping the base URL. Only the model slug changes between models.

JavaScript · openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "microsoft/phi-4",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(completion.choices[0].message.content);

Model slug: microsoft/phi-4

Editor's verdict

Our take on Phi 4

Phi 4 is Microsoft's open-weight language models with a 16K-token context window.

On independent testing it scores 10.4 on the Artificial Analysis Intelligence Index, running at roughly 33 tokens per second with about 2.11s to first token.

At $0.14 per 1M output tokens, it is very cost-efficient for its class.

As an open-weight model you can self-host it or call it through a hosted API.

Best suited to strong reasoning for model size and efficient inference.

Did you find this helpful?

Frequently asked questions

Phi 4 supports a context length of 16384 tokens.

User reviews

Real, verified reviews from the community shape this model's rating.

Loading reviews…

Sign in to review

Other Phi models

Sibling versions in the Phi family from Microsoft.

Promote Phi 4

Add this badge to your website, or share the tool.

DFeatured on DhanasviPhi 4 0