Skip to content

Phi-4

phi-4

Phi-4 by Microsoft.

Context
16.4K tokens
Endpoint
Get API KeyCompare

Pricing

Input$0.21 / 1M
Output$0.42 / 1M
Cache Write (5m)$0.21 / 1M
Cache Write (1h)$0.21 / 1M
Cache Read$0.21 / 1M
Web Search$0 / 1M

Quick Start

Select an endpoint and copy a working example for this model.

Endpoint
python
from openai import OpenAI client = OpenAI(    api_key="YOUR_API_KEY",    base_url="https://api.apertis.ai/v1") response = client.chat.completions.create(    model="phi-4",    messages=[        {"role": "user", "content": "Hello!"}    ],    max_tokens=1024,    temperature=0.7) print(response.choices[0].message.content) # Optional: Enable context compression to reduce token usage# response = client.chat.completions.create(#     model="phi-4",#     messages=[{"role": "user", "content": "Hello!"}],#     extra_body={"compression": {"enabled": True, "model": "gpt-4.1-mini"}}# )

Supported Parameters

API docs
Common7 params
modelmessagesmax_tokenstemperaturetop_pstreamtools
Extended4 params
reasoning_effortstream_optionsthinkingextra_body

Cursor IDE Model IDs

Use these namespaced identifiers in Cursor IDE to avoid conflicts with built-in models.

phi-4

Compare with Other Models

See how this model compares to others from the same provider.