ai-hedge-fund के लिए custom API setup

Updated 2026-09-05

Endpoint configuration से पहले provider selection आता है। Current model factory और registry का पालन करें, फिर data, agent output और evaluation को अलग stages में validate करें।

Current application path पहचानें

Current ai-hedge-fund application के लिए OPENAI_API_BASE set करने से पहले model के registry provider की पुष्टि करें। Revision fc1bf250 पर client factory hedge_fund/llm/client.py में है और उसके पास वाली registry पढ़ती है। केवल src/llm/models.py का उल्लेख करने वाले पुराने tutorials अलग application path बताते हैं। अपना checkout pin करें और current factory import करने वाला entrypoint इस्तेमाल करें। नीचे provider preflight से शुरू करें, फिर complete research cycle के लिए financial data collect करने से पहले project client exercise करें।

Base URL set करने से पहले provider resolve करें

make_llm चुने हुए model identifier से provider चुनता है। उसका OpenAI branch OPENAI_API_BASE को ChatOpenAI में pass करता है और संबंधित API key पढ़ता है। Reviewed source में unknown identifier Anthropic transport पर fallback करता है, इसलिए केवल OpenAI base URL export करना पर्याप्त नहीं। पहले पुष्टि करें कि exact endpoint model ID OpenAI के तहत registered है। यहां OpenAI transport adapter को पहचानता है; यह underlying model vendor को certify नहीं करता। Global registry entry बदलने से पहले समझें कि उसे इस्तेमाल करने वाले हर workflow पर क्या असर होगा।

Settingउद्देश्यजांच
HEDGE_FUND_LLM_MODELExact model ID चुननाRegistry intended provider तक resolve हो
OPENAI_API_BASEOpenAI transport endpoint override करनायह OpenAI branch पर लागू हो
OPENAI_API_KEYउस transport को authenticate करनाClient process को उपलब्ध हो
api_models.jsonModel IDs को providers से map करनाCurrent path hedge_fund/llm/ है

Request किए बिना configuration inspect करें

नीचे का example client construction से पहले fail होता है अगर local registry अलग transport चुनती है। RESEARCH_MODEL_ID को उस catalog ID पर set करें जिसकी application registration आपने review की है। Absent होने पर existing display_name, model_name और provider fields का उपयोग करके local registry row जानबूझकर जोड़ें और unrelated entries सुरक्षित रखें। Placeholder supported model claim नहीं है। Key environment या secret store से दें। यह preflight केवल selection check करता है; network access, account entitlement, structured output या research quality सिद्ध नहीं कर सकता।

import os
from hedge_fund.llm.registry import provider_for

model = os.environ["RESEARCH_MODEL_ID"]
if provider_for(model) != "OpenAI":
    raise RuntimeError("MODEL_TRANSPORT_MISMATCH")
os.environ["HEDGE_FUND_LLM_MODEL"] = model
os.environ["OPENAI_API_BASE"] = "https://api.apisrouter.com/v1"
assert os.environ["OPENAI_API_KEY"]
# Selection check only; no make_llm() or model request.

Proposed model route trace करें

Model route registry resolution के बाद शुरू होता है। Application को अभी भी financial data client, universe definition और explicit research date चाहिए। Gateway key Financial Datasets credential या market data redistribute करने का अधिकार नहीं है। Company identifiers, currency और timestamp semantics को स्वतंत्र रूप से validate करें। Cross-listed companies के लिए स्पष्ट करें कि analysis issuer, local share class या depositary receipt के बारे में है। Model-request evidence को provider-data evidence से अलग रखें, ताकि missing financial series को LLM problem न समझा जाए।

Model registry selection के बाद ai-hedge-fund OpenAI transport route।ai-hedge-fund routes through OpenAI registry provider + OPENAI_API_BASE to the APIsRouter gateway (api.apisrouter.com/v1), which fans out to: Registered research model.ai-hedge-fundviaOpenAI registryprovider +OPENAI_API_BASEAPIsRouterapi.apisrouter.com/v1Registered research model
Provider selection के बाद documented client route। Financial data अपना client इस्तेमाल करता है।

Parsed decisions को data की तरह validate करें

Reviewed factory provider clients को complete(system, user) method के पीछे wrap करती है। उसका response text अपने-आप valid research result नहीं। Agent layer देखें जो JSON parse करती है, abstention संभालती है और outputs जोड़ती है। Response nonempty होकर भी malformed, internally contradictory या inputs से unsupported हो सकता है। Raw redacted response और parsed object को एक request record में रखें। Reassuring sentence match करने के बजाय expected fields और allowed states validate करें। Missing या rejected result को unavailable रखें; उसे portfolio aggregation में चुपचाप आने वाला neutral signal न बनाएं।

import os
from hedge_fund.llm.client import make_llm, extract_json
from hedge_fund.llm.registry import provider_for

model = os.environ["HEDGE_FUND_LLM_MODEL"]
assert provider_for(model) == "OpenAI"
client = make_llm(model=model)
result = extract_json(client.complete(
    "Return a JSON object with a boolean ready field.",
    "Set ready to true.",
))
assert result.get("ready") is True
# This request tests the client and parser, not financial research.

पहला research cycle छोटा और reviewable रखें

Authorized client test के बाद licensed या public evidence वाला एक issuer और bounded question चुनें। हर required tool ने सही company और period लौटाया या नहीं, जांचें और generated explanation को original documents से compare करें। Initial run read-only रखें और explicit human review step बचाएं। देखें कि output supporting और opposing evidence cite करता है, missing data record करता है और assumptions को calculations से अलग रखता है। Analyst role या investing style का नाम इस बात का evidence नहीं कि generated reasoning किसी real व्यक्ति के methods या judgment को दोहराती है।

Backtest evidence को स्वतंत्र रखें

Application research cycle पूरा कर सकती है, जबकि उसका historical evaluation invalid हो। Publication timestamps, revised data, surviving-company selection और historical prompts में current news के उपयोग की जांच करें। Prompts या strategy settings पर iteration से पहले development, validation और held-out periods अलग करें। Benchmark, transaction-cost assumptions और हर attempted configuration सुरक्षित रखें। उसी test period के आधार पर prompt बार-बार चुनने से वह period development data बन जाता है। अधूरे evaluation को ईमानदारी से report करें; illustrative return भरकर ऐसी results table न बनाएं जिसे measurement समझ लिया जाए।

Failures और कुल research spend नियंत्रित करें

Job level पर model calls, retries, parsing failures, financial-data charges और local computation गिनें। Usage reconcile होने तक endpoint timeout की billing unknown रह सकती है। Transient transport failures को fixed budget में retry करें; authentication या provider-selection failures को unchanged retry न करें। Failed stage और उसका sanitized error review के लिए बचाएं। Generic gateway hello transport isolate करने में मदद कर सकता है, लेकिन केवल project के अपने client tests उसके adapter behavior को जांचते हैं। उपयोगी cost comparison में model candidates के बीच source packet, roles और output acceptance criteria समान रखें।

प्रमाण और सीमाएं

Current factory और registry को September 5, 2026 को fc1bf250 पर review किया गया। Examples source-backed templates हैं; इस guide के लिए कोई APIsRouter request या full research cycle execute नहीं किया गया। अन्य gateways के पुराने calls इस integration को सिद्ध नहीं करते। Environment validate करते समय client, data-tool और complete-artifact results अलग रखें।

अक्सर पूछे जाने वाले प्रश्न

मेरी custom ID Anthropic key क्यों मांगती है?

Reviewed factory में unregistered model ID Anthropic पर fallback करती है। Client construction से पहले provider_for(model) और current hedge_fund/llm/api_models.json registry जांचें।

क्या OPENAI_API_BASE हर provider को reroute करता है?

नहीं। इसे OpenAI client branch पढ़ती है। अन्य registry providers अपने clients बनाते हैं और अलग settings इस्तेमाल कर सकते हैं।

कौन-से registry fields relevant हैं?

Reviewed registry display_name, model_name और provider पढ़ती है। Exact endpoint ID सुरक्षित रखें और transport जानबूझकर चुनें।

क्या application menu में model होने का मतलब endpoint access है?

नहीं। चुने हुए endpoint से exact ID और account access जांचें। Application registry client selection तय करती है, gateway catalog नहीं।

Client JSON लौटाने के बाद क्या जांचूं?

Financial-data tools, agent output schema, abstention behavior और final evidence-linked research artifact को bounded task से validate करें।

क्या मैं output से order automatically place कर सकता हूं?

यह guide research configuration कवर करती है। Order authorization, limits, reconciliation और operational review अलग से validated execution system में होने चाहिए।