Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
LLM_Interface、OpenAICompatible、OpenAIResponsesCompatible、APIKeyPool 的 API 参考
from SimpleLLMFunc.interface import LLM_Interface
LLM_Interface( api_key_pool: APIKeyPool, model_name: str, base_url: Optional[str] = None, context_window: int = 200_000, )
chat
async def chat(*, trace_id, stream=False, messages, timeout=None, **kwargs)
chat_stream
async def chat_stream(*, trace_id, stream=True, messages, timeout=None, **kwargs) -> AsyncGenerator
model_name
str
base_url
str | None
context_window
int
api_key_pool
APIKeyPool
from SimpleLLMFunc import OpenAICompatible
OpenAICompatible( api_key_pool: APIKeyPool, model_name: str, base_url: str, max_retries: int = 5, retry_delay: float = 1.0, rate_limit_capacity: int = 10, rate_limit_refill_rate: float = 1.0, context_window: int = 200_000, )
load_from_json_file(path)
Dict[str, Dict[str, OpenAICompatible]]
get_rate_limit_status()
Dict[str, Any]
reset_rate_limit()
None
from SimpleLLMFunc import OpenAICompatible, APIKeyPool # From file models = OpenAICompatible.load_from_json_file("provider.json") llm = models["openrouter"]["openai/gpt-4o"] # Direct llm = OpenAICompatible( api_key_pool=APIKeyPool(api_keys=["sk-..."], provider_id="openai"), model_name="gpt-4o", base_url="https://api.openai.com/v1", rate_limit_capacity=20, rate_limit_refill_rate=5.0, )
from SimpleLLMFunc import OpenAIResponsesCompatible
OpenAICompatible
messages[0].role="system"
instructions
reasoning={...}
from SimpleLLMFunc import OpenAIResponsesCompatible, APIKeyPool llm = OpenAIResponsesCompatible( api_key_pool=APIKeyPool(api_keys=["sk-..."], provider_id="openai"), model_name="gpt-4o", base_url="https://api.openai.com/v1", ) @llm_chat(llm_interface=llm, reasoning_effort="high") async def reasoning_agent(message: str, history: list | None = None): """Reason carefully about the question.""" pass
from SimpleLLMFunc import APIKeyPool
APIKeyPool( api_keys: List[str], provider_id: str, )
pool = APIKeyPool( api_keys=["sk-key-1", "sk-key-2", "sk-key-3"], provider_id="openrouter-gpt4o", ) # Keys are rotated on each call automatically
from SimpleLLMFunc import TokenBucket
TokenBucket( capacity: int, refill_rate: float, )
capacity
refill_rate
此页面对您有帮助吗?