Skip to main content

Your SDK and model zoo for generative AI. Build AI-powered applications with ease.

Project description

fastSDK. Any service. One typed client.

PyPI version Python versions GitHub License

Turn any hosted service into a typed Python client.

Point fastSDK at an OpenAPI spec and get a Python client with a method per endpoint,
typed parameters, file uploads, and job handling. Call web APIs like plain functions.

Why

You built a web service with FastAPI, Flask, Cog, or APIPod. Now you need a Python client.

Hand-writing one with requests works until it does not. You add endpoints. You run calls in parallel. You transfer a 1GB video and the request times out. You fall into threading and asyncio complexity, and the client drifts out of sync with the API.

fastSDK generates the client from your spec. Endpoints become typed methods. Files upload and stream. Long-running calls return a job you can wait on or cancel. The heavy I/O runs concurrently under the hood through meseex, so your code stays synchronous and simple.

Install

pip install fastsdk

Quick start

Grab your service's openapi.json (usually at http://localhost:8000/openapi.json), then generate a client:

from fastsdk import FastSDK

# generate a client file from the spec
FastSDK().create_sdk("openapi.json", save_path="my_service.py", class_name="MyService")

The generated file has one method per endpoint, with every parameter and default. Import it and call it:

from my_service import MyService

client = MyService(api_key="my_api_key")
job = client.my_method(...)          # returns a job immediately, does not block
result = job.wait_for_result()       # typed result back

Need a one-off client without writing a file? Skip generation:

from fastsdk import FastSDK

client = FastSDK().create_temporary_client("openapi.json", api_key="my_api_key")

Jobs

Every endpoint call returns a job. Start many, collect them later.

job = client.my_method(...)

job.wait_for_result()   # block until done, return the typed result
job.cancel()            # cancel locally if queued, or ask the provider to cancel

For job-based providers (APIPod, Runpod, Socaity, Replicate), fastSDK polls remote status and reports progress until the job reaches a terminal state.

Files

File parameters accept paths or media-toolkit objects. Large files upload to cloud storage (Azure Blob, Amazon S3) and are passed by URL; results come back as typed media objects you can save.

from fastsdk import ImageFile

job = client.swap_img_to_img("face_1.jpg", "face_2.jpg")
result = job.wait_for_result()
result.save("swapped.jpg")

MediaFile, ImageFile, VideoFile, and AudioFile are importable straight from the package.

API keys

Pass the key when you create the client, or read it from the environment:

import os
from my_service import MyService

client = MyService(api_key=os.getenv("MY_API_KEY"))

Service compatibility

Works out of the box with:

Provider Notes
OpenAPI 3.0 / REST FastAPI, Flask, any compliant spec
APIPod job-based services
Runpod serverless GPU endpoints
Cog Replicate-style services
Socaity hosted models
Replicate prediction APIs

fastSDK and APIPod

APIPod builds and deploys the services. fastSDK calls them. Two halves of the same client-to-service loop, designed for long-running ML and data workloads.

Architecture

For internals (definition layer, runtime pipeline, cancellation, how meseex fits in) see TECHNICAL_README.md.

Status

Alpha. Syntax and surface change rapidly. Bug reports, ideas, and pull requests are welcome in the issues section.

fastSDK is licensed under GPLv3 and free to use. Leave a star to support us.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastsdk-0.2.33.tar.gz (73.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastsdk-0.2.33-py3-none-any.whl (63.0 kB view details)

Uploaded Python 3

File details

Details for the file fastsdk-0.2.33.tar.gz.

File metadata

  • Download URL: fastsdk-0.2.33.tar.gz
  • Upload date:
  • Size: 73.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for fastsdk-0.2.33.tar.gz
Algorithm Hash digest
SHA256 4a3a852ac23ab92d4459b8490af7d4d389aaa1309fb2f28e5b29eea7d3114e2b
MD5 e3694a8444af186e74ea024a1fc80dc0
BLAKE2b-256 4a3ced82caeac54ad8c7a21411c9a70565e6bd674c1e4aeadaba7cec6c8f4623

See more details on using hashes here.

File details

Details for the file fastsdk-0.2.33-py3-none-any.whl.

File metadata

  • Download URL: fastsdk-0.2.33-py3-none-any.whl
  • Upload date:
  • Size: 63.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for fastsdk-0.2.33-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b011b643551a1ac7905d092e1edaa148661ac464c3902238f492fe134c8ebf
MD5 dbefb7e0ba1ecb7956ac7ff805fe8ef1
BLAKE2b-256 d69917e8e2c55d891efc44f4dbf6638025f2a7fcda256525f525244502c863f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page