AI / Core OpenAI Codex Application Fundamentals Interview Questions
What is the OpenAI Codex and API pricing model and how do you estimate costs?
OpenAI uses a pay-per-token pricing model for API access. For Codex CLI and App, costs are consumed from your ChatGPT or API credits balance. Understanding the cost structure helps in designing cost-efficient applications.
| Model | Input price | Output price | Use case |
|---|---|---|---|
| gpt-5.5 | ~$5/1M tokens | ~$20/1M tokens | API general use |
| gpt-5.4-mini | ~$0.60/1M tokens | ~$2.40/1M tokens | Lightweight tasks, subagents |
| codex-mini-latest | $1.50/1M tokens | $6/1M tokens | CLI-optimised Q&A |
| gpt-5.3-codex-spark | Metered (high-throughput) | Metered | Pro plan only, 1000+ tps |
| Batch API (any model) | ~50% of standard | ~50% of standard | Bulk non-real-time workloads |
| text-embedding-3-small | ~$0.02/1M tokens | N/A | Embeddings for RAG |
# Cost estimation example: # Scenario: Code review agent processes 100 PRs/day # Average PR: 2000 input tokens + 500 output tokens = 2500 tokens daily_prs = 100 avg_input_tokens = 2000 avg_output_tokens = 500 # Using gpt-5.5 at standard pricing: input_cost_per_million = 5.00 output_cost_per_million = 20.00 daily_input_cost = (daily_prs * avg_input_tokens / 1_000_000) * input_cost_per_million daily_output_cost = (daily_prs * avg_output_tokens / 1_000_000) * output_cost_per_million daily_total = daily_input_cost + daily_output_cost monthly_total = daily_total * 30 print(f"Daily cost: ${daily_total:.2f}") print(f"Monthly cost: ${monthly_total:.2f}") # With Batch API (50% discount): batch_monthly = monthly_total * 0.5 print(f"Monthly cost (Batch API): ${batch_monthly:.2f}") # With prompt caching (40% cache hit rate, 75% discount on cached): # Effective input cost reduction ~30% # + Batch API = significant overall saving
Cost reduction hierarchy: choose the right model for the task (biggest lever) > use prompt caching > use Batch API for bulk > use smaller models for sub-tasks > use streaming to reduce perceived latency without changing cost.
More Related questions...