managarten/services/mana-research/src/lib/pricing.ts
Till JS f10a95e842 feat(mana-research): add Gemini 3.1 Pro Deep Research async providers
- New providers gemini-deep-research + gemini-deep-research-max on the
  Interactions API (preview-04-2026). Submit/poll split, tier parameter
  selects between standard (~minutes, $1–3) and max (up to 60 min, $3–7).
- Parser matches the real response shape: flat `outputs` array of
  thought|text|image items, url_citation annotations without title,
  `usage.total_input_tokens` / `total_output_tokens`.
- Route generalisation: /v1/research/async accepts `provider` with
  default 'openai-deep-research' (backward compatible) and dispatches
  to the right submit/poll pair.
- New internal service-to-service endpoint /v1/internal/research/async
  gated by X-Service-Key + X-User-Id for credit accounting. Enables
  mana-ai to drive deep-research jobs on the mission owner's wallet
  without requiring a user JWT.
- Pricing: 300 credits (standard) / 1500 credits (max). Conservative
  markup over the ~$3/$7 ceiling so the first runs can't surprise us.
- Docs: AGENT_PROVIDER_IDS + pricing + env map + auto-router stay in
  sync; CLAUDE.md Phase 3b now current; API_KEYS.md references the
  new providers under GOOGLE_GENAI_API_KEY.

Verified with a real smoke test against the Gemini API: submit + poll
both succeed, completed response parsed cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:55:30 +02:00

48 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Provider pricing in credits. 1 credit ≈ 1 cent EUR (matches mana-credits).
*
* Keep in sync with docs/plans/mana-research-service.md §2. Review quarterly.
* Prices as of 2026-04-17.
*/
import type { ProviderId } from '@mana/shared-research';
export const PROVIDER_PRICING: Record<
ProviderId,
{ search?: number; extract?: number; research?: number }
> = {
// Search providers
searxng: { search: 0 },
duckduckgo: { search: 0 },
brave: { search: 5 },
tavily: { search: 8 },
exa: { search: 6 },
serper: { search: 1 },
// Extract providers
readability: { extract: 0 },
'jina-reader': { extract: 1 },
firecrawl: { extract: 10 },
scrapingbee: { extract: 8 },
// Research agents
'perplexity-sonar': { research: 50 },
'claude-web-search': { research: 200 },
'openai-responses': { research: 200 },
'gemini-grounding': { research: 100 },
'openai-deep-research': { research: 1000 },
// Gemini Deep Research (preview-04-2026). Google lists $13 per standard
// task and $37 per Max task. 1 credit ≈ 1 cent EUR, so $3 ≈ 300 credits
// and a Max task can hit ~$7 ≈ 700 credits with markup → start
// conservative (see docs/reports/gemini-deep-research.md §4).
'gemini-deep-research': { research: 300 },
'gemini-deep-research-max': { research: 1500 },
};
export function priceFor(
providerId: ProviderId,
operation: 'search' | 'extract' | 'research'
): number {
const entry = PROVIDER_PRICING[providerId];
return entry?.[operation] ?? 0;
}