Tools Evaluation
Tool Evaluation with OpenAI Evals
This cookbook shows how to measure and improve a model’s ability to extract structured information from source code with tool evaluation. In this case, the set of symbols (functions, classes, methods, and variables) defined in Python files.
Setup
Install the latest openai Python package ≥ 1.14.0 and set your OPENAI_API_KEY environment variable. If you also want to evaluate an assistant with tools, enable the Assistants v2 beta in your account.
pip install --upgrade openai
export OPENAI_API_KEY=sk‑...
Below we import the SDK, create a client, and define a helper that builds a small dataset from files inside the openai package itself.
[notice] A new release of pip is available: 24.0 -> 25.1.1 [notice] To update, run: pip install --upgrade pip Note: you may need to restart the kernel to use updated packages.
Dataset factory & grading rubric
get_datasetbuilds a small in-memory dataset by reading several SDK files.structured_output_graderdefines a detailed evaluation rubric.sampled.output_tools[0].function.arguments.symbolsspecifies the extracted symbols from the code file based on the tool invocation.client.evals.create(...)registers the eval with the platform.
Evals Creation
Here we create an eval that will be used to evaluate the quality of extracted information from code files.
Kick off model runs
Here we launch two runs against the same eval: one that calls the Completions endpoint, and one that calls the Responses endpoint.
Utility Poller
We create a utility poller that will be used to poll for the results of the eval runs.
Visualize Evals Dashboard
You can navigate to the Evals Dashboard in order to visualize the data.

You can also take a look at the explanation of the failed results in the Evals Dashboard after the run is complete as shown in the image below.

This notebook demonstrated how to use OpenAI Evals to assess and improve a model’s ability to extract structured information from Python code using tool calls.
OpenAI Evals provides a robust, reproducible framework for evaluating LLMs on structured extraction tasks. By combining clear tool schemas, rigorous grading rubrics, and well-structured datasets, you can measure and improve overall performance.
For more details, see the OpenAI Evals documentation.