cookbook/LiteLLM_batch_completion.ipynb
batch_completion!pip install litellm
import os
from litellm import batch_completion
# set your API_KEY
os.environ['ANTHROPIC_API_KEY'] = ""
litellm.batch_completionIn the batch_completion method, you provide a list of messages where each sub-list of messages is passed to litellm.completion(), allowing you to process multiple prompts efficiently in a single API call.
import os
os.environ['ANTHROPIC_API_KEY'] = ""
responses = batch_completion(
model="claude-2",
messages = [
[
{
"role": "user",
"content": "good morning? "
}
],
[
{
"role": "user",
"content": "what's the time? "
}
]
]
)
responses