Phi 4
VerifiedMicrosoft's Phi-4 offers efficient open-weight text reasoning.
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
Benchmarks & performance
Independent evaluation scores and measured speed.
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
Speed
Output tokens per second · Higher is better · Phi 4 ranks #43 of 45
Price
USD per 1M output tokens · Lower is better · Phi 4 ranks #16 of 141
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.
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.
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
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.
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…
Other Phi models
Sibling versions in the Phi family from Microsoft.