or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mddatamodel.mdevaluation.mdfine-tuning.mdindex.mdmodels.mdprompts.mdrag-embeddings.mdtask-execution.mdtools.md

models.mddocs/

0

# Model Registry

1

2

Comprehensive registry of supported AI models and embedding models with capability metadata, provider configurations, and model discovery functions.

3

4

## Capabilities

5

6

### Model Discovery

7

8

Functions for discovering and retrieving model information.

9

10

```python { .api }

11

from kiln_ai.adapters.ml_model_list import get_model_by_name, built_in_models_from_provider

12

13

def get_model_by_name(model_name: str):

14

"""

15

Retrieve model definition by name.

16

17

Parameters:

18

- model_name (str): Model identifier (e.g., "gpt_4o", "claude_3_5_sonnet")

19

20

Returns:

21

KilnModel | None: Model definition or None if not found

22

"""

23

24

def built_in_models_from_provider(provider_name: str) -> list:

25

"""

26

List all built-in models for a provider.

27

28

Parameters:

29

- provider_name (str): Provider identifier (e.g., "openai", "anthropic", "groq")

30

31

Returns:

32

list[KilnModel]: List of model definitions

33

"""

34

35

def default_structured_output_mode_for_model_provider(

36

model_id: str,

37

provider: str

38

):

39

"""

40

Get default structured output mode for model and provider.

41

42

Parameters:

43

- model_id (str): Model identifier

44

- provider (str): Provider name

45

46

Returns:

47

StructuredOutputMode: Default output mode (none, json, or structured)

48

"""

49

```

50

51

### Model Definitions

52

53

Core model definition classes with capability metadata.

54

55

```python { .api }

56

class KilnModel:

57

"""

58

Model definition with capabilities.

59

60

Properties:

61

- name (str): Model name/identifier

62

- family (ModelFamily): Model family (gpt, claude, llama, etc.)

63

- provider (KilnModelProvider): Provider configuration

64

- context_window (int): Maximum context window size in tokens

65

- supports_vision (bool): Whether model supports image inputs

66

- parser_id (ModelParserID): Parser for output processing

67

- formatter_id (ModelFormatterID): Formatter for input processing

68

- supports_streaming (bool): Whether model supports streaming

69

- supports_tools (bool): Whether model supports tool/function calling

70

- supports_structured_output (bool): Whether model supports structured JSON output

71

"""

72

73

class KilnModelProvider:

74

"""

75

Model provider configuration.

76

77

Properties:

78

- name (str): Provider name (e.g., "openai", "anthropic")

79

- supports_streaming (bool): Provider supports streaming responses

80

- supports_tools (bool): Provider supports tool/function calling

81

- supports_structured_output (bool): Provider supports structured output

82

"""

83

```

84

85

### Model Families

86

87

Enumeration of model families for categorization.

88

89

```python { .api }

90

class ModelFamily:

91

"""

92

Categories of model families.

93

94

Values:

95

- gpt: OpenAI GPT models

96

- claude: Anthropic Claude models

97

- llama: Meta Llama models

98

- mistral: Mistral AI models

99

- gemini: Google Gemini models

100

- qwen: Alibaba Qwen models

101

- deepseek: DeepSeek models

102

- command: Cohere Command models

103

- titan: AWS Titan models

104

- phi: Microsoft Phi models

105

- wizardlm: WizardLM models

106

- yi: 01.AI Yi models

107

- mixtral: Mixtral models

108

"""

109

gpt = "gpt"

110

claude = "claude"

111

llama = "llama"

112

mistral = "mistral"

113

gemini = "gemini"

114

qwen = "qwen"

115

deepseek = "deepseek"

116

command = "command"

117

titan = "titan"

118

phi = "phi"

119

wizardlm = "wizardlm"

120

yi = "yi"

121

mixtral = "mixtral"

122

```

123

124

### Model Names

125

126

Enumeration of supported model identifiers.

127

128

```python { .api }

129

class ModelName:

130

"""

131

Supported model identifiers.

132

133

Common values:

134

- gpt_4o: OpenAI GPT-4o

135

- gpt_4o_mini: OpenAI GPT-4o Mini

136

- gpt_4_turbo: OpenAI GPT-4 Turbo

137

- gpt_3_5_turbo: OpenAI GPT-3.5 Turbo

138

- claude_3_5_sonnet: Anthropic Claude 3.5 Sonnet

139

- claude_3_opus: Anthropic Claude 3 Opus

140

- claude_3_haiku: Anthropic Claude 3 Haiku

141

- llama_3_1_405b: Meta Llama 3.1 405B

142

- llama_3_1_70b: Meta Llama 3.1 70B

143

- llama_3_1_8b: Meta Llama 3.1 8B

144

- mistral_large: Mistral Large

145

- mistral_nemo: Mistral Nemo

146

- gemini_1_5_pro: Google Gemini 1.5 Pro

147

- gemini_1_5_flash: Google Gemini 1.5 Flash

148

- qwen_2_5_72b: Alibaba Qwen 2.5 72B

149

- deepseek_chat: DeepSeek Chat

150

"""

151

gpt_4o = "gpt-4o"

152

gpt_4o_mini = "gpt-4o-mini"

153

gpt_4_turbo = "gpt-4-turbo"

154

gpt_3_5_turbo = "gpt-3.5-turbo"

155

claude_3_5_sonnet = "claude-3-5-sonnet-20241022"

156

claude_3_opus = "claude-3-opus-20240229"

157

claude_3_haiku = "claude-3-haiku-20240307"

158

llama_3_1_405b = "llama-3.1-405b-instruct"

159

llama_3_1_70b = "llama-3.1-70b-instruct"

160

llama_3_1_8b = "llama-3.1-8b-instruct"

161

mistral_large = "mistral-large-latest"

162

mistral_nemo = "mistral-nemo"

163

gemini_1_5_pro = "gemini-1.5-pro"

164

gemini_1_5_flash = "gemini-1.5-flash"

165

qwen_2_5_72b = "qwen-2.5-72b-instruct"

166

deepseek_chat = "deepseek-chat"

167

```

168

169

### Parser and Formatter IDs

170

171

Identifiers for model input/output processing.

172

173

```python { .api }

174

class ModelParserID:

175

"""

176

Parser identifiers for model outputs.

177

178

Values:

179

- default: Standard output parser

180

- r1_thinking: Parser for R1-style reasoning outputs

181

"""

182

default = "default"

183

r1_thinking = "r1_thinking"

184

185

class ModelFormatterID:

186

"""

187

Formatter identifiers for model inputs.

188

189

Values:

190

- default: Standard input formatter

191

- qwen3_no_think: Qwen3 formatter without thinking tags

192

"""

193

default = "default"

194

qwen3_no_think = "qwen3_no_think"

195

```

196

197

### Embedding Models

198

199

Discovery and configuration for embedding models.

200

201

```python { .api }

202

from kiln_ai.adapters.ml_embedding_model_list import (

203

get_model_by_name,

204

built_in_embedding_models_from_provider

205

)

206

207

def get_model_by_name(model_name: str):

208

"""

209

Get embedding model by name.

210

211

Parameters:

212

- model_name (str): Embedding model identifier

213

214

Returns:

215

KilnEmbeddingModel | None: Model definition or None if not found

216

"""

217

218

def built_in_embedding_models_from_provider(provider_name: str) -> list:

219

"""

220

List embedding models for provider.

221

222

Parameters:

223

- provider_name (str): Provider identifier

224

225

Returns:

226

list[KilnEmbeddingModel]: List of embedding model definitions

227

"""

228

229

class KilnEmbeddingModel:

230

"""

231

Embedding model definition.

232

233

Properties:

234

- name (str): Model name/identifier

235

- family (KilnEmbeddingModelFamily): Model family

236

- provider (KilnEmbeddingModelProvider): Provider configuration

237

- dimensions (int): Embedding vector dimensions

238

- max_input_tokens (int): Maximum input tokens

239

"""

240

241

class KilnEmbeddingModelProvider:

242

"""

243

Embedding provider configuration.

244

245

Properties:

246

- name (str): Provider name

247

- default_dimensions (int): Default embedding dimensions

248

"""

249

```

250

251

### Embedding Model Families

252

253

Categories of embedding model families.

254

255

```python { .api }

256

class KilnEmbeddingModelFamily:

257

"""

258

Embedding model families.

259

260

Values:

261

- openai: OpenAI embedding models

262

- cohere: Cohere embedding models

263

- voyage: Voyage AI embedding models

264

- sentence_transformers: Sentence Transformers models

265

"""

266

openai = "openai"

267

cohere = "cohere"

268

voyage = "voyage"

269

sentence_transformers = "sentence_transformers"

270

```

271

272

### Embedding Model Names

273

274

Supported embedding model identifiers.

275

276

```python { .api }

277

class EmbeddingModelName:

278

"""

279

Supported embedding models.

280

281

Values:

282

- text_embedding_3_small: OpenAI text-embedding-3-small

283

- text_embedding_3_large: OpenAI text-embedding-3-large

284

- text_embedding_ada_002: OpenAI text-embedding-ada-002

285

- embed_english_v3: Cohere embed-english-v3.0

286

- embed_multilingual_v3: Cohere embed-multilingual-v3.0

287

- voyage_large_2: Voyage AI voyage-large-2

288

- voyage_code_2: Voyage AI voyage-code-2

289

"""

290

text_embedding_3_small = "text-embedding-3-small"

291

text_embedding_3_large = "text-embedding-3-large"

292

text_embedding_ada_002 = "text-embedding-ada-002"

293

embed_english_v3 = "embed-english-v3.0"

294

embed_multilingual_v3 = "embed-multilingual-v3.0"

295

voyage_large_2 = "voyage-large-2"

296

voyage_code_2 = "voyage-code-2"

297

```

298

299

## Usage Examples

300

301

### Discovering Models

302

303

```python

304

from kiln_ai.adapters.ml_model_list import (

305

get_model_by_name,

306

built_in_models_from_provider

307

)

308

309

# Get specific model

310

model = get_model_by_name("gpt_4o")

311

if model:

312

print(f"Model: {model.name}")

313

print(f"Family: {model.family}")

314

print(f"Context window: {model.context_window}")

315

print(f"Supports vision: {model.supports_vision}")

316

print(f"Supports streaming: {model.supports_streaming}")

317

print(f"Supports tools: {model.supports_tools}")

318

319

# List all OpenAI models

320

openai_models = built_in_models_from_provider("openai")

321

for model in openai_models:

322

print(f"- {model.name} (context: {model.context_window})")

323

324

# List all Anthropic models

325

anthropic_models = built_in_models_from_provider("anthropic")

326

for model in anthropic_models:

327

print(f"- {model.name}")

328

```

329

330

### Checking Model Capabilities

331

332

```python

333

from kiln_ai.adapters.ml_model_list import get_model_by_name

334

335

def check_model_capabilities(model_name: str):

336

model = get_model_by_name(model_name)

337

if not model:

338

print(f"Model {model_name} not found")

339

return

340

341

print(f"Model: {model.name}")

342

print(f"Provider: {model.provider.name}")

343

print(f"Capabilities:")

344

print(f" - Vision: {model.supports_vision}")

345

print(f" - Streaming: {model.supports_streaming}")

346

print(f" - Tools: {model.supports_tools}")

347

print(f" - Structured Output: {model.supports_structured_output}")

348

print(f" - Context Window: {model.context_window} tokens")

349

350

# Check various models

351

check_model_capabilities("gpt_4o")

352

check_model_capabilities("claude_3_5_sonnet")

353

check_model_capabilities("llama_3_1_8b")

354

```

355

356

### Working with Embedding Models

357

358

```python

359

from kiln_ai.adapters.ml_embedding_model_list import (

360

get_model_by_name,

361

built_in_embedding_models_from_provider

362

)

363

364

# Get specific embedding model

365

model = get_model_by_name("text_embedding_3_small")

366

if model:

367

print(f"Model: {model.name}")

368

print(f"Dimensions: {model.dimensions}")

369

print(f"Max tokens: {model.max_input_tokens}")

370

371

# List all OpenAI embedding models

372

openai_embeddings = built_in_embedding_models_from_provider("openai")

373

for model in openai_embeddings:

374

print(f"- {model.name}: {model.dimensions}D")

375

376

# Compare embedding models

377

models_to_compare = [

378

"text_embedding_3_small",

379

"text_embedding_3_large",

380

"embed_english_v3"

381

]

382

383

for model_name in models_to_compare:

384

model = get_model_by_name(model_name)

385

if model:

386

print(f"{model.name}:")

387

print(f" Provider: {model.provider.name}")

388

print(f" Dimensions: {model.dimensions}")

389

print(f" Max input: {model.max_input_tokens} tokens")

390

```

391

392

### Filtering Models by Capability

393

394

```python

395

from kiln_ai.adapters.ml_model_list import built_in_models_from_provider

396

397

# Find all models that support vision

398

def find_vision_models(provider: str):

399

models = built_in_models_from_provider(provider)

400

vision_models = [m for m in models if m.supports_vision]

401

return vision_models

402

403

openai_vision = find_vision_models("openai")

404

print("OpenAI models with vision support:")

405

for model in openai_vision:

406

print(f" - {model.name}")

407

408

# Find models with large context windows

409

def find_large_context_models(min_tokens: int):

410

providers = ["openai", "anthropic", "google"]

411

large_context = []

412

413

for provider in providers:

414

models = built_in_models_from_provider(provider)

415

for model in models:

416

if model.context_window >= min_tokens:

417

large_context.append(model)

418

419

return large_context

420

421

large_models = find_large_context_models(100000)

422

print(f"\nModels with 100K+ context:")

423

for model in large_models:

424

print(f" - {model.name}: {model.context_window:,} tokens")

425

```

426

427

### Using with Adapters

428

429

```python

430

from kiln_ai.adapters import adapter_for_task

431

from kiln_ai.adapters.ml_model_list import get_model_by_name, ModelName

432

from kiln_ai.datamodel import Task

433

434

# Use model name enum for type safety

435

task = Task(

436

name="test_task",

437

instruction="Test instruction"

438

)

439

440

# Create adapter using model name

441

adapter = adapter_for_task(

442

task,

443

model_name=ModelName.gpt_4o,

444

provider="openai"

445

)

446

447

# Or verify model exists before creating adapter

448

model_to_use = "claude_3_5_sonnet"

449

model_info = get_model_by_name(model_to_use)

450

451

if model_info:

452

print(f"Using {model_info.name} with {model_info.context_window} context")

453

adapter = adapter_for_task(task, model_name=model_to_use, provider="anthropic")

454

else:

455

print(f"Model {model_to_use} not found")

456

```

457

458

### Custom Models

459

460

```python

461

from kiln_ai.utils.config import Config

462

463

# Add custom model to existing provider

464

new_model = "openai::gpt-3.5-turbo-custom"

465

custom_models = Config.shared().custom_models or []

466

467

if new_model not in custom_models:

468

custom_models.append(new_model)

469

Config.shared().custom_models = custom_models

470

Config.shared().save()

471

print(f"Added custom model: {new_model}")

472

473

# List all custom models

474

print("Custom models:")

475

for model in Config.shared().custom_models:

476

print(f" - {model}")

477

```

478

479

### Structured Output Support

480

481

```python

482

from kiln_ai.adapters.ml_model_list import (

483

get_model_by_name,

484

default_structured_output_mode_for_model_provider

485

)

486

from kiln_ai.datamodel import StructuredOutputMode

487

488

# Check structured output support

489

model_name = "gpt_4o"

490

provider = "openai"

491

492

model = get_model_by_name(model_name)

493

if model and model.supports_structured_output:

494

mode = default_structured_output_mode_for_model_provider(model_name, provider)

495

print(f"{model_name} supports structured output")

496

print(f"Default mode: {mode}")

497

498

if mode == StructuredOutputMode.structured:

499

print("Full schema validation available")

500

elif mode == StructuredOutputMode.json:

501

print("JSON mode available")

502

```

503