Retrivum

Design the API behind your AI app.

A companion exercise for the AI App Development course: define a small question-answering API before connecting it to a model. The downloadable schemas are teaching examples, not a hosted API.

API design workshop · Modules 2 / 7

Work through these modules

Module 02 · Integrate a model API properly Module 07 · Build the application experience

Workshop resources

Download the teaching schema

Module 2 · Model API integration

Write your project handover

What you’ll practise

  • Define and validate a request-response contract.
  • Keep model credentials on the server and handle failures safely.
  • Verify the API with deterministic fixtures before adding a model.

What to submit

  • An OpenAPI contract adapted to your own app.
  • A local question-answering endpoint with input validation.
  • Successful and failed request examples with expected results.

Your project tasks

Start with a clear contract

Define a POST /ask operation that accepts a question and returns an answer, citations, and a request identifier. Keep model credentials on your own server. The example schema uses example.invalid so it cannot accidentally target a live service.

  • Specify required fields and length limits.
  • Describe unsupported input and structured error responses.
  • Use synthetic questions and documents while developing.

Implement and test locally

Create a local server for the exercise, validate the request, and return a deterministic fixture first. Add a model integration only after the contract and error handling work.

  • Test missing questions, oversized requests, and provider timeouts.
  • Keep error messages useful without exposing credentials or stack traces.
  • Measure response quality, latency, and estimated cost before deployment.

Completion check

Submit the API contract, a local implementation, and examples of successful and failed requests. Explain how your application validates input and verifies citations. Continue with modules 2, 7, and 8 in the AI App Development curriculum.

    Completion criteria

    • The API rejects missing or oversized questions with a structured error.
    • A deterministic fixture demonstrates the response shape before model integration.
    • Credentials never appear in browser code, logs, or submitted examples.
    • The handover distinguishes the teaching schema from the local implementation.

    Back to the course curriculum