This package provides a unified function, llm_call, for interacting with various LLM APIs, including OpenAI, Anthropic, and Google Gemini, powered by the litellm library. It also provides a wrapper for OpenAI's embedding API.
def llm_call(prompt: str, model: Optional[str] = None, **kwargs: Any) -> str:Wrapper for OpenAI, Anthropic, and Google calls using litellm.
Parameters:
prompt(str): The user's input prompt.model(str): The model to use, in the format<provider>/<model>(e.g., "openai/gpt-6.1-sol").**kwargs: Additional parameters passed tolitellm.completion, such as:system_prompt(str, optional): System message to set context.temperature(float, optional): Controls randomness in output.max_tokens(int, optional): Maximum number of tokens in the response.
Supported Providers:
openai: For OpenAI models (e.g., "openai/gpt-6.1-sol").anthropic: For Anthropic models (e.g., "anthropic/claude-opus-5-5").gemini: For Google Gemini models (e.g., "gemini/gemini-3.8-flash").
Returns:
- str: The generated text response from the language model.
Example:
from wordcel.llms import llm_call
response = llm_call("What is the capital of France?", model="openai/gpt-6.1-sol")
print(response)def openai_embed(text, model="text-embedding-3-small")Wrapper function for OpenAI's embedding API.
Parameters:
text(str): The input text to embed.model(str, optional): The embedding model to use. Default: "text-embedding-3-small"
Returns:
- list: The embedding vector for the input text.
Example:
from wordcel.llms import openai_embed
embedding = openai_embed("Hello, world!")
print(len(embedding)) # Print the dimensionality of the embeddingThe following environment variables are used by these functions:
OPENAI_API_KEY: Required for OpenAI API calls.ANTHROPIC_API_KEY: Required for Anthropic API calls.GEMINI_API_KEY: Required for Google Gemini API calls.
response = llm_call("Tell me a joke", model="openai/gpt-6.1-sol")response = llm_call("Explain machine learning", model="gemini/gemini-3.8-flash")response = llm_call("Write a poem about nature", model="anthropic/claude-opus-5-5")