games.chess.api_example¶

FastAPI example for chess game with configurable LLMs.

This module demonstrates how to create API endpoints for chess games with configurable LLM providers and models.

Classes¶

CreateGameRequest

Request to create a new chess game.

GameResponse

Response with game information.

GameStateResponse

Response with current game state.

LLMConfig

LLM configuration for a player.

MoveStreamEvent

Event streamed during game execution.

Functions¶

create_game(request)

Create a new chess game.

delete_game(game_id)

Delete a game.

get_game_state(game_id)

Get the current state of a game.

list_games()

List all active games.

list_providers()

List available LLM providers.

root()

Root endpoint with API information.

stream_game(game_id, background_tasks)

Stream game execution events.

Module Contents¶

class games.chess.api_example.CreateGameRequest(/, **data)¶

Bases: pydantic.BaseModel

Request to create a new chess game.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class games.chess.api_example.GameResponse(/, **data)¶

Bases: pydantic.BaseModel

Response with game information.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class games.chess.api_example.GameStateResponse(/, **data)¶

Bases: pydantic.BaseModel

Response with current game state.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class games.chess.api_example.LLMConfig(/, **data)¶

Bases: pydantic.BaseModel

LLM configuration for a player.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class games.chess.api_example.MoveStreamEvent(/, **data)¶

Bases: pydantic.BaseModel

Event streamed during game execution.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

async games.chess.api_example.create_game(request)¶

Create a new chess game.

Parameters:

request (CreateGameRequest)

async games.chess.api_example.delete_game(game_id)¶

Delete a game.

Parameters:

game_id (str)

async games.chess.api_example.get_game_state(game_id)¶

Get the current state of a game.

Parameters:

game_id (str)

async games.chess.api_example.list_games()¶

List all active games.

async games.chess.api_example.list_providers()¶

List available LLM providers.

async games.chess.api_example.root()¶

Root endpoint with API information.

async games.chess.api_example.stream_game(game_id, background_tasks)¶

Stream game execution events.

Parameters:
  • game_id (str)

  • background_tasks (fastapi.BackgroundTasks)