Passing field value to #autocomplete_route_name in custom form
You need to define #autocomplete_route_parameters. I'm not sure if the form gets rebuilt during autocomplete queries (most likely not!) so you might need to define a #ajax on the vocabulary selector in order to rebuild the form and return the taxonomy_terms field with correct parameters set. This way you're defining a clear dependency, that field 2's available values depend on field 1's value. Below code is untested, but hopefully pushed you in the right direction:

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['taxonomy'] = [
    '#type' =&gt; 'select',
    '#title' =&gt; $this-&gt;t('Select Taxonomy'),
    '#options' =&gt; $taxonomies,
    '#ajax' =&gt; [
      'callback' =&gt; 'Namespace\To\Your\Entity::vocabulary_callback',
      'event' =&gt; 'change',
      'wrapper' =&gt; 'term-wrapper'
    ],
  ];

  // Initially return a disabled field.
  $form['taxonomy_terms'] = [
    '#type' =&gt; 'textfield',
    '#disabled' =&gt; TRUE,
    '#prefix' =&gt; '&lt;div id="term-wrapper"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  ];

  // If someone's chosen a vocabulary, rewrite the field.
  if ($vid = $form_state-&gt;getValue('taxonomy', false)) {
    $form['taxonomy_terms'] = [
      '#type' =&gt; 'textfield',
      '#prefix' =&gt; '&lt;div id="term-wrapper"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
      '#autocomplete_route_name' =&gt; 'unido_drupal_admin.get_taxonomies',
      '#autocomplete_route_parameters' =&gt; ['vid' =&gt; $vid],
    ];
  }

  return $form;
}

public function vocabulary_callback(array &amp;$form, FormStateInterface $form_state) {
  return $form['taxonomy_terms'];
}


You also need to define this as a route parameter in your route's path element:

unido_drupal_admin.get_taxonomies:
  path: '/path/to/your/autocomplete/{vid}'


And also accept the parameter in your autocomplete function:

public function get_taxonomies(Request $request, $vid) {


There might be better ways to do this though, but with my limited D8 knowledge, this is how I'd approach it.