Phi 4 API

Run microsoft/phi-4 through FastInfra's OpenAI-compatible API. Pay per token, no subscription, routed to the cheapest available provider.

Read the docs
Pricing

Phi 4 pricing

Billed per token used. Prices sync automatically from wholesale providers.

Direction Price per 1M tokens
Input$0.07
Output$0.15
Availability

Served by 2 providers

Requests route to DeepInfra by default (cheapest). Pin a specific provider with the :provider suffix.

Provider Upstream model ID
openrouter microsoft/phi-4
deepinfra microsoft/phi-4
Quickstart

Call Phi 4 in 30 seconds

Works with any OpenAI SDK — change the base URL and API key only.

Python

from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.fastinfra.ai/v1")

response = client.chat.completions.create(
    model="microsoft/phi-4",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

curl

curl https://api.fastinfra.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "microsoft/phi-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
FAQ

Phi 4 — common questions

How much does the microsoft/phi-4 API cost?

On FastInfra, microsoft/phi-4 costs $0.0735/1M input, $0.147/1M output tokens. Billing is per token used, with no subscription.

Is microsoft/phi-4 compatible with the OpenAI SDK?

Yes. FastInfra exposes microsoft/phi-4 through an OpenAI-compatible endpoint at https://api.fastinfra.ai/v1 — point any OpenAI SDK at that base URL with a FastInfra API key and keep your existing code.

Which providers serve microsoft/phi-4?

microsoft/phi-4 is available from 2 provider(s): openrouter, deepinfra. Requests route to DeepInfra by default (cheapest); append ":provider" to the model ID to pin one.