Skip to content

External APIs

Since this project is powered by RESPX, all API calls to HTTPX or HTTP Core will be patched. If a route is not mocked, then this will result in an error.

For example, if you're calling to external APIs for function calling and you're testing these function calls with this project, then you will need to add a custom mock for that route.

A respx.Router instance is exposed from the main OpenAIMock object. This allows you to use the interface provided by RESPX to define your own mock.

openai_mock.router.post(url="https://api.myweatherapi.com").mock(Response(200, json={"value": "57"}))

See full example here or view RESPX mocking docs here.

Pass Through

If you want a call to not be mocked and actually be sent to an external service, then you can use RESPX's pass through feature.

openai_mock.router.post(url="https://api.myweatherapi.com").pass_through()