Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
check:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.14"]
include:
- os: ubuntu-latest
python-version: "3.10"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v6

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- run: uv sync

- name: Lint
run: |
uv run poe lint
uv run poe typecheck

- name: Generate API and check for diff
run: |
uv run poe generate-api
git diff --exit-code

- name: Test
env:
# Forks won't have these secrets so e2e tests skip, but pushes
# to main will run them.
BASETEN_E2E_TEST_API_KEY: ${{ secrets.BASETEN_E2E_TEST_API_KEY }}
BASETEN_E2E_TEST_DOMAIN: ${{ secrets.BASETEN_E2E_TEST_DOMAIN }}
BASETEN_E2E_TEST_MODEL_ID: ${{ secrets.BASETEN_E2E_TEST_MODEL_ID }}
run: uv run poe test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.pytest_cache
.ruff_cache
.venv
__pycache__
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing

## Setup

```bash
uv sync
```

## Tasks

All tasks are run via `uv run poe <task>`:

- `generate-api` - Regenerate API clients and models from OpenAPI specs (pass `--update-specs` to download latest specs first)
- `format` - Format code and auto-fix lint issues
- `lint` - Check formatting and lint (fails on issues)
- `typecheck` - Run type checker
- `test` - Run tests

## End-to-End Tests

E2e tests in `tests/test_e2e.py` run against a live Baseten environment. They are skipped automatically when `BASETEN_E2E_TEST_API_KEY` is not set.

### Bootstrap

Deploy a minimal test model (requires `truss`):

```bash
BASETEN_E2E_TEST_API_KEY=... BASETEN_E2E_TEST_DOMAIN=... \
uv run --with truss python -m scripts.e2e_test_bootstrap
```

This prints the model ID to stdout. Wait for the model to be ready before running tests.

### Running

```bash
BASETEN_E2E_TEST_API_KEY=... \
BASETEN_E2E_TEST_DOMAIN=... \
BASETEN_E2E_TEST_MODEL_ID=... \
uv run poe test tests/test_e2e.py
```
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Baseten Python SDK

Under development.
Python SDK for Baseten.

⚠️ Under active development. Nothing should be considered stable at this time.

## Usage

Current SDK only has barebones client. Here is usage example of the barebones underlying client:

```python
from baseten.client import ManagementClient

with ManagementClient(api_key="my-api-key") as client:
for model in client.api.get_models().models:
print(model.name)
```

Or for async:

```python
from baseten.client import AsyncManagementClient

async with AsyncManagementClient(api_key="my-api-key") as client:
for model in (await client.api.get_models()).models:
print(model.name)
```
Empty file added baseten/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions baseten/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Baseten client library.

Use :class:`ManagementClient` or :class:`AsyncManagementClient` for the
management API, and :class:`InferenceClient` or :class:`AsyncInferenceClient`
for the inference API.
"""

from baseten.client._inference import (
AsyncInferenceClient,
InferenceClient,
InferenceClientOptions,
)
from baseten.client._management import (
AsyncManagementClient,
ManagementClient,
ManagementClientOptions,
)

__all__ = [
"AsyncInferenceClient",
"AsyncManagementClient",
"InferenceClient",
"InferenceClientOptions",
"ManagementClient",
"ManagementClientOptions",
]
Loading
Loading