DeepInfra

Use DeepInfra models with Kern agents.

Leverage DeepInfra's powerful command models and more.

DeepInfra supports a wide range of models. See their library of models here.

We recommend experimenting to find the best-suited model for your use-case. Here are some general recommendations:

  • deepseek-ai/DeepSeek-R1-Distill-Llama-70B model is good for reasoning.
  • meta-llama/Llama-2-70b-chat-hf model is good for basic use-cases.
  • meta-llama/Llama-3.3-70B-Instruct model is good for multi-step tasks.

DeepInfra has rate limits. See the docs for more information.

Authentication

Set your DEEPINFRA_API_KEY environment variable. Get your key from here.

1export DEEPINFRA_API_KEY=***
1setx DEEPINFRA_API_KEY ***

Example

Use DeepInfra with your Agent:

1from kern.agent import Agent
2from kern.models.deepinfra import DeepInfra
3
4agent = Agent(
5 model=DeepInfra(id="meta-llama/Llama-2-70b-chat-hf"),
6 markdown=True
7)
8
9# Print the response in the terminal
10agent.print_response("Share a 2 sentence horror story.")
Note View more examples here.

Params

ParameterTypeDefaultDescription
idstr"meta-llama/Llama-2-70b-chat-hf"The id of the DeepInfra model to use
namestr"DeepInfra"The name of the model
providerstr"DeepInfra"The provider of the model
api_keyOptional[str]NoneThe API key for DeepInfra (defaults to DEEPINFRA_API_KEY env var)
base_urlstr"https://api.deepinfra.com/v1/openai"The base URL for the DeepInfra API

DeepInfra also supports the parameters of OpenAI.