`model_select` vs. `create`

Not Diamond is not a proxy. Its core functionality is to take in an array of messages and a list of LLMs and return a recommendation for which LLM is best-suited to respond. You can then make your LLM calls in whatever way you choose.

In the Not Diamond Python and Typescript SDK, recommendations are made with the model_select method. For ease of use, our SDKs also have an additional set of optional dependencies you can include when installing the Not Diamond package which adds the create method. The create method will directly facilitate requests to LLM providers client-side.

When to use model_select

model_select may be the better option if you'd like to use Not Diamond in an existing project. The core notdiamond package is lightweight and reduces the risk of dependency conflicts, and you can use any existing code you've implemented to execute requests to LLMs within your project:

pip install notdiamond
npm install notdiamond
# Using model_select

session_id, provider = client.chat.completions.model_select(
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Concisely explain merge sort."}
    ],
  	model=['openai/gpt-4o', 'anthropic/claude-3-5-sonnet-20240620']
)
const result = await notDiamond.modelSelect({
  messages: [{ content: 'What is 12x12?', role: 'user' }],
  llmProviders: [
    { provider: 'openai', model: 'gpt-4o' },
    { provider: 'anthropic', model: 'claude-3-5-sonnet-20240620' }
  ]
});

When to use create

On the other hand, create may be the more useful method if you are spinning up a new project from scratch and don't want to write boilerplate code for executing your LLM calls:

pip install notdiamond[create]
npm install notdiamond
# Using create

result, session_id, provider = client.chat.completions.create(
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Concisely explain merge sort."}
    ],
  	model=['openai/gpt-4o', 'anthropic/claude-3-5-sonnet-20240620']
)
const result = await notDiamond.create({
  messages: [{ content: 'What is 12x12?', role: 'user' }],
  llmProviders: [
    { provider: 'openai', model: 'gpt-4o' },
    { provider: 'anthropic', model: 'claude-3-5-sonnet-20240620' }
  ]
});

Most examples in our docs use the create method, but you can switch this out for model_select at any point if you prefer.