Quickstart
Create an account and API key, choose a model, then send and stream a request with an OpenAI SDK or curl.
1. Create an account and API key.
Create your account and sign in. Use an API key—not your account session—to authenticate API requests.
- Create a Blaschke account with a verified email, then sign in.
- In your account, open the API keys section and select “Create key.” Give the key a name and create it. Copy the complete key when it appears and store it securely; you won’t be able to view it again. Blaschke API keys begin with
blsk_.
2. Set your environment and select a model.
List available models, then export your API key and the exact model ID you want to use. The examples read both variables from your environment.
export BLASCHKE_API_KEY="blsk_..."
export BLASCHKE_MODEL="<exact-model-id>"curl --fail --silent --show-error https://beta.blaschkelabs.com/v1/models \
-H "Authorization: Bearer $BLASCHKE_API_KEY"Copy an id returned by GET /v1/models into BLASCHKE_MODEL. Use an Available model, not an Upcoming catalog entry.
3. Send a request.
Use POST /v1/chat/completions with an OpenAI SDK or curl. The SDK examples disable automatic retries, and each example sets max_tokens to 256.
Install
python -m pip install openaiSend a request
import os
from openai import OpenAI
client = OpenAI(
base_url="https://beta.blaschkelabs.com/v1",
api_key=os.environ["BLASCHKE_API_KEY"],
max_retries=0,
)
response = client.chat.completions.create(
model=os.environ["BLASCHKE_MODEL"],
messages=[{"role": "user", "content": "Explain Blaschke in two sentences."}],
max_tokens=256,
)
print(response.model)
print(response.choices[0].message.content)Check that the returned model matches your selection.
4. Stream the answer.
Set stream: true for server-sent events. Add stream_options.include_usage: true to request token usage at the end. The final usage event may contain no text.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://beta.blaschkelabs.com/v1",
api_key=os.environ["BLASCHKE_API_KEY"],
)
stream = client.chat.completions.create(
model=os.environ["BLASCHKE_MODEL"],
messages=[{"role": "user", "content": "What is a Blaschke product?"}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)
if chunk.usage:
print("\nUsage:", chunk.usage)