Element-API: Access the first url of an asset array
you could use array_values() to fetch the first image:

...
      'transformer' =&gt; function (Entry $entry) {
        foreach ($entry-&gt;images as $image) {
          $images[] = $image-&gt;url;
        }
        return [
          'images' =&gt;  array_values($images)[0],
        ];
      },
...


or use reset()

...
      'transformer' =&gt; function (Entry $entry) {
        foreach ($entry-&gt;images as $image) {
          $images[] = $image-&gt;url;
        }
        return [
          'images' =&gt;  reset($images),
        ];
      },
...